1.变量解析
{name:'zhang'}
{name}
>>>>>
['jack','bob','tom']
{.}
>>>>
jack bob tom
{friends:[
{name:'tom'},
{name:'jack'},
{name:'jone'}
]
}
{#friends}
{name} - {$idx}-{$len}
{/friends}
>>>>
tom - 0 - 3
jack - 1 - 3
jone - 2 - 3
4.获取数组长度
{friends:[
{name:'tom'},
{name:'jack'},
{name:'jone'}
]
}
{@size key=friends/}
>>>>
3
{A:{
name:'A',
B:{
name:'B'
}
}
}
{#A.B} B的scope:{name}----A的scope:{A.name}{/A.B}
>>>>
B的scope:B ---- A的scope:A
{A:{name:'A'},B:{type:'TB'}}
{#A:B} A的name:{name},B的type:{type}{/A}
>>>>
A的name:A,B的type:TB
{?A}
这里A为true
{:else}
这里A为false
{/A}
>>>>
{^A}
这里A为false
{:else}
这里A为true
{/A}
{@select key=foo}
{@any}Congratulations! You got: {/any} //任何一个满足就会展示any中内容
{@eq value="1"}First Place{/eq}
{@eq value="2"}Second Place{/eq}
{@eq value="3"}Third Place{/eq}
{@none}Better luck next time!{/none} //所有都不满足就会展示none中内容
{/select}
9.{@math}
{@math key="16" method="add" operand="4"/} - Result will be 20
{@math key="16.5" method="floor"/} - Result will be 16
{@math key="16.5" method="ceil"/} - Result will be 17
{@math key="-8" method="abs"/} - Result will be 8
{@math key="{$idx}" method="mod" operand="2"/} - Return 0 or 1 according to $idx value
{@math key="13" method="add" operand="12"}
{@gt value=123}
13 + 12 > 123
{/gt}
{@none}
Math is fun
{/none}
{/math}
//测试后,发现@if不起作用。
12.{@sep},忽略数组中中后一项的处理
foo:[{name:'A'},{name:'B'},{name:'C'}]
{#foo}
{name}{@sep},{/sep}
{/foo}
>>>>
A,B,C