TT3: /home/abw/web/london/tt3/slides/examples/generators.tt3

Template Source

[% numbers = [ item * 3 for 1 to 10 ] %] [% numbers.join(', ') -%] --EOF--

Source Tokens

tag_start@0[%
whitespace@2
variable@4numbers
whitespace@11
operator assign@12=
whitespace@13
construct list@14[
whitespace@15
variable@16item
whitespace@20
number multiply@21*
whitespace@22
number@233
whitespace@24
command for@25for
whitespace@28
number@291
whitespace@30
number to@31to
whitespace@33
number@3410
whitespace@36
terminator@37]
whitespace@38
tag_end@40%]
text@42\n\n
tag_start@44[%
whitespace@46
variable@48numbers
operator dot@55.
word@56join
construct parens@60(
squote string@61', '
terminator@65)
whitespace@66
tag_end@67-%]
whitespace@70\n
eof@71

Parse Tree

binary expr@12numbers = [ for ]
variable element@4numbers
=
list expr@14[ for ]
[
for keyword@25for
List
binary expr@311 to 10
number element@291
to
number element@3410
Then
binary expr@21item * 3
variable element@16item
*
number element@233
]
text@42\n\n
binary expr@55numbers.join
variable element@48numbers
.
word element@56join

Variables Used

item
Uses
@ line 1[% numbers = [ item * 3 for 1 to 10 ] %]
numbers
Uses
@ line 1[% numbers = [ item * 3 for 1 to 10 ] %]
@ line 3[% numbers.join(', ') -%]
Vars
join
Uses
@ line 3[% numbers.join(', ') -%]

Generated Output

3, 6, 9, 12, 15, 18, 21, 24, 27, 30