1.swig通常在js文件里引入方法: __inline(*.tpl),以下图所示html
2.特殊用法app
swig模板里套用swig模板,<link rel="import" href="./*.tpl?__inline">.以下图,spa
3.swig里防止转译 {{ stringHtml|safe }}xml
4. swig的filterhtm
filters.js:blog
swig.setFilter('numdate',function(timestr,option){
var date = new Date(parseInt(timestr)*1000 + 1000*60*60*8);
return date;
});ci
中国日期错误缘由:string
症状为明明是23号,用swig date filter后显示日期为22号。it
缘由是因为swig默认使用的国际标准时区,中国大于国际标准时区8个小时io
解决方案:偏差减去 480m
html:
{{ item.apply_time|numdate|date('Y-m-d H:i', -480) }}
5. 随时提醒能够输入多少字符 string.length
<textarea name="company_publicity" id="company_publicity" cols="30" rows="10" placeholder="请输入公司文化">{{ company_publicity }}</textarea><p class="reply-prompt">你还能够输入<span class="char">{{ 300-company_publicity.length }}</span>个字符</p>