A More Complex Template

[% if order.items.size -%] <ul> [% for order.items -%] <li>[% item.quantity %] [% item.description %]</li> [% end -%] </ul> [% end -%] --EOF--
look inside...
Thus Spake Andy:

Here's a more complex example. Keywords are now in lower case and FOREACH has become just for. Otherwise things are pretty much the same. Note the use of the - chomping flags at the end of the tags to eat the newlines following the tag. In TT3 we call these inline tags.

Before moving on, check out the HTML debugging for this template (click on the 'look inside' link - there's a link for every example in this presentation). In particular, look at the Output tab. TT3's error handling is much improved. In this case we get a runtime error indicating some undefined data. You get the line number (and I mean the proper line number, not the start of the tag which could be miles away as it is in TT2), a description of the error, and an extract of the source code complete with "^ here" marker. I punch myself in the face (figuratively speaking) every time I get lost trying to debug a TT2 template. Never again! The Variables and Tree tabs are also worth a look, and don't forget to click on the boxes.