#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 - - String
${\ this is a backslash: \\\\\
${'It\\'s \ this is a backslash: }
${r\
raw字符串,原封不动地现实引号中的内容
ps:前一种是用双引号来引用字符串,后一种是用单引号来引用字符串。 分别需要对双引号和单引号进行转义
${\ ${user + user + user + user} 效果相同
★substring ${user[0]}${user[4]}
${user[1..4]} ${user[4..]} ★number 不支持科学计数法 小数点前面的零不能省略 ★sequences
<#list [\ ${x} #list>
<#list 2..5 as x> ${x} #list> <#list [2,3,4,5] as x> ${x} #list>
数组的拼接
<#list [\ - ${user} #list> ★hash
<#assign ages = {\ - Joe is ${ages.Joe} - Fred is ${ages.Fred} - Julia is ${ages.Julia}
注意重复的键对应的值取最后的一个 ★运算
${5/2?int} 显示2
cap_first : 首字母大写
capitalize: 所有单词首刺目大写
html : 转换为HTML格式 < replaced with < > replaced with > & replaced with & \ index_of : 显示元素所在的位置 \返回值为1(下标从0开始)
Contains:判断是否存在字符
<#if \输出: It contains \
Replace :替换
split(―XX‖):截取XX之后的字符
<#list \- ${x} #list> 输出: - some - test - text
starts_with :字符串由什么开始返回布尔型
trim :去掉空格
seq_index_of 数组中元素的位置
<#assign colors = [\${colors?seq_index_of(\输出: 2
Default : 设置变量的默认值
Exists:放在if句 如果没有…..
<#if mouse?exists> Mouse found <#else>
No mouse found #if>
Creating mouse...
<#assign mouse = \<#if mouse?exists> Mouse found <#else>
No mouse found #if> 输出 :
No mouse found Creating mouse...