技术 · 2018 年 10 月 8 日

Twig的函数过滤器

老是要用到过滤器,记录一下:

abs
取绝对值
batch

capitalize
convert_encoding
date
指定日期时间格式

date_modify

default
escape
first
format
join
json_encode
keys
last
length
lower
merge
nl2br
number_format
raw
replace
替换指定的字符,单个格式:|replace({‘要替换的字符’:”替换后的字符”});多个替换:|replace({‘要替换的字符’:”替换后的字符”,’要替换的字符2′:”替换后的字符2″})

reverse
round
slice
sort
split
striptags
去除 HTML 和 PHP 标记,只保留文本。

title
trim
upper
url_encode


文档:
https://twig.symfony.com/doc/2.x/ 
参考:
https://www.cnblogs.com/kuyuecs/p/4428717.html