cycle?能夠接受一個(gè)叫做?cycle group?的參數(shù),以便滿足你在模版中需要使用多個(gè)?cycle?代碼塊的情況。如果沒有為 cycle group 命名,那么將會(huì)假定帶有相同參數(shù)的 cycle 調(diào)用屬于同一個(gè)組(group)。
tablerow
生成一個(gè) HTML 表格。必須用?<table>?和?</table>?這兩個(gè) HTML 標(biāo)簽將其包裹起來。
輸入
<table>
{%tablerow product in collection.products %}{{product.title}}{%endtablerow%}
</table>
輸出
<table><trclass="row1"><tdclass="col1">
Cool Shirt
</td><tdclass="col2">
Alien Poster
</td><tdclass="col3">
Batman Poster
</td><tdclass="col4">
Bullseye Shirt
</td><tdclass="col5">
Another Classic Vinyl
</td><tdclass="col6">
Awesome Jeans
</td></tr></table>
tablerow (parameters)
cols
定義表格應(yīng)當(dāng)有多少列。
輸入
{%tablerow product in collection.products cols:2%}{{product.title}}{%endtablerow%}
輸出
<table><trclass="row1"><tdclass="col1">
Cool Shirt
</td><tdclass="col2">
Alien Poster
</td></tr><trclass="row2"><tdclass="col1">
Batman Poster
</td><tdclass="col2">
Bullseye Shirt
</td></tr><trclass="row3"><tdclass="col1">
Another Classic Vinyl
</td><tdclass="col2">
Awesome Jeans
</td></tr></table>
limit
在執(zhí)行到指定的腳標(biāo)(index)之后退出 tablerow 。
{%tablerow product in collection.products cols:2limit:3%}{{product.title}}{%endtablerow%}
offset
在指定的腳標(biāo)(index)之后開始執(zhí)行 tablerow 。
{%tablerow product in collection.products cols:2offset:3%}{{product.title}}{%endtablerow%}
range
定義循環(huán)執(zhí)行的范圍??衫脭?shù)字和變量來定義執(zhí)行范圍。
<!--variable number example-->
{%assignnum=4%}
<table>
{%tablerow i in (1..num)?%}{{i}}{%endtablerow?%}
</table>
<!--literal number example-->
<table>
{%tablerow i in (3..5)?%}{{i}}{%endtablerow?%}
</table>