user?html 给出 user 的HTML转义版本, 比如 & 会由 & 来代替。
user?upper_case 给出 user 值的大写版本 (比如 "JOHN DOE" 来替代 "John Doe")
animal.name?cap_first 给出 animal.name 的首字母大写版本(比如 "Mouse" 来替代 "mouse")
user?length 给出 user 值中 字符的数量(对于 "John Doe" 来说就是8)
如果在 <#list animals as animal> 和对应的 </#list> 标签中:
animal?index 给出了在 animals 中基于0开始的 animal的索引值
animal?counter 也像 index, 但是给出的是基于1的索引值
animal?item_parity 基于当前计数的奇偶性,给出字符串 "odd" 或 "even"。给不同行着色时有用
比如在 <td class="${animal?item_parity}Row">中
一些内建函数需要参数来指定行为,比如:
animal.protected?string("Y", "N") 基于 animal.protected 的布尔值来返回字符串 "Y" 或 "N"。
animal?item_cycle(‘lightRow‘,‘darkRow‘) 是之前介绍的 item_parity 更为常用的变体形式。
fruits?join(", ") 通过连接所有项,将列表转换为字符串, 在每个项之间插入参数分隔符(比如 "orange,banana")
user?starts_with("J") 根据 user 的首字母是否是 "J" 返回布尔值true或false。
更多内建函数方法:http://freemarker.foofun.cn/ref_builtins.html
原文:https://www.cnblogs.com/haimao/p/12458897.html