模板過濾器 - truncatewords_html
定義和用法
truncatewords_html
過濾器會在值超過指定的單詞數時截斷它。
truncatewords_html
過濾器不會計算任何 HTML 標籤,但會閉合未結束的標籤。
如果值被截斷,字串末尾會新增三個點 (...)。
另請參閱
truncatewords
truncatechars
truncatechars_html
語法
{{ value|truncatewords_html:number }}
模板過濾器透過使用豎線 |
字元後跟過濾器名稱來定義。
引數透過使用冒號 :
字元後跟引數值來定義。
引數
值 | 描述 |
---|---|
數字 | 必需。一個數字,指定允許的字元數。 |