结束标签
可以在结束标签中忽略user_def_dir_exp 也就是说可以写</@>来代替</@anything>
循环变量
<@myRepeatMacro count=4> SomeThing... </@> <@myRepeatMacro count=4 ;x> ${x}.SomeThing... </@> <@myRepeatMacro count=4 ;x,last> //自定义指令创建的循环变量和分号之后指定的循环变量数量需要不匹配 last可以不写 x也可以不写 ${x}.Something...<#if last>This was the last!</#if> </@>
位置参数传递: 目前仅仅支持宏定义
macro,nested,return指令
没有参数的宏 <#macro test> Test text </#macro> <@test/> --> Test text 有参数的宏: <#macro test foo bar baaz> Test test,and the params:${foo},${bar},${baaz} </#macro> <@test foo="a" bar="b" baaz=5*5-2/> --> Test text,and the params:a,b,23 一个复杂的宏 <#macro list title items> <p>${title?cap_first}: <ul> <#list> <li>${x?cap_first} </#list> </ul> </#macro> <@list item=["mouse","elephant","python"] title="Animals"/> --> <p>Animals: <ul> <li>Mouse <li>Elephant
<li>Python </ul>
function return 指令
<#function name param1 param2 ... paramN> ... <#return returnVlalue> ... </#function>
例子:
<#function avg x y >
<#return (x+y)/2>
</#function>
${avg(10,20)}
-->15