1. String内置的JavaScript转换: js_string
用途:用于JavaScript转义,转换',",换行等特殊字符
模板:
输出:
2.内置的默认值处理:default
用途: 用于处理默认值
模本:
User:
${userLogin.name?default("Anonymous")}
${(employee.department.manager.name)?default(" ")} |
输出: User: Anonymous | 注,可以对整个对象树加上(),再用内置处理器这种方便的做法,偶也是最近刚学会的,以前一直用很傻的方法做.....
3. Sequence内置的计数器: xxx_index
用途:显示序号 模板:
<#list employees as e>
${e_index}. ${e.name} #list> 输出:
1. Readonly 2. Robbin 4.
Sequence内置的分段器: chunk 用途:某些比较BT的排版需求
模板: <#assign seq = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
'j']> <#list seq?chunk(4) as row>
<#list row as cell>${cell}
#list>
#list> <#list seq?chunk(4, '-') as row>
<#list
row as cell>${cell} #list> |
#list>
输出: a
b c d e f g h i j
a |
b |
c |
d |
e |
f |
g |
h |
i |
j |
- |
- |
阅读(1657) | 评论(0) | 转发(0) |