to facebook前端bug修復:Freemarker 進行字符串截取

在這裏插入圖片描述

當字符串長度大於某一個值時,進行截取,使用下面的方式:thing.title?length gt 33

<#if thing.title?length gt 33>
${thing.title?substring(0,30)}…
<#else>
${thing.title!}
</#if>
當然,也可以對thing.title 外面添加括號,(thing.title)?length gt 33

處理好的截圖,如下:

在這裏插入圖片描述
是不是好看多了,呵呵。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章