capitalize:大写首字母
date(format[, tzOffset]):转换日期为指定格式
format:格式
tzOffset:时区
default(value):默认值(如果变量为undefined,null,false)
escape([type]):转义字符
默认: &, <, >, “, ‘
js: &, <, >, “, ‘, =, -, ;
first:返回数组第一个值
join(glue):同[].join
json_encode([indent]):类似JSON.stringify, indent为缩进空格数
last:返回数组最后一个值
length:返回变量的length,如果是object,返回key的数量
lower:同”.toLowerCase()
raw:指定输入不会被转义
replace(search, replace[, flags]):同”.replace
reverse:翻转数组
striptags:去除html/xml标签
title:大写首字母
uniq:数组去重
upper:同”.toUpperCase
url_encode:同encodeURIComponent
url_decode:同decodeURIComponemt
使用方法:
例如我们要格式化一个时间,使用方法和linux上的管道命令非常像
{{ birthday|date('Y-m-d') }}大写首字母
{{ name|title }}9.set命令
用来设置一个变量,在当前上下文中复用
{% set foo = [0, 1, 2, 3, 4, 5] %}
{% for num in foo %}
<li>{{ num }}</li>
{% endfor %}参考文献:http://www.iqianduan.net/blog/how_to_use_swig









