#foreach($i in $items) #each (this is optional since its the default section) text which appears for each item #before text which appears before each item #after text which appears after each item #between text which appears between each two items #odd text which appears for every other item, including the first #even text which appears for every other item, starting with the second #nodata Content rendered if $items evaluated to null or empty #beforeall text which appears before the loop, only if there are items matching condition #afterall text which appears after the loop, only of there are items matching condition #end
比如如下的一个例子:
#foreach($person in $people) #beforeall <table> <tr> <th>Name</th> <th>Age</th> </tr> #before <tr #odd Style='color:gray'> #even Style='color:white'> #each <td>$person.Name</td> <td>$person.Age</td> #after </tr> #between <tr><td colspan='2'>$person.bio</td></tr> #afterall </table> #nodata Sorry No Person Found #end
#if($order == "Undefined") Sorry, but we don't know this order. #elseif($order == "Created") Your order is being processed. Hold on! #elseif($order == "Dispatched") Your order has been dispatched through UPS. Cross your fingers! #end