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

Template Source

[% hello = block(name) %] Hello [% name or 'World' %]! [% end %] [% hello('World') %] [% hello('Badger') %] --EOF--

Source Tokens

tag_start@0[%
whitespace@2
variable@3hello
whitespace@8
operator assign@9=
whitespace@10
command block@11block
construct parens@16(
variable@17name
terminator@21)
whitespace@22
tag_end@23%]
text@25\nHello
tag_start@32[%
whitespace@34
variable@35name
whitespace@39
binary operator@40or
whitespace@42
squote string@43'World'
whitespace@50
tag_end@51%]
text@53!\n
tag_start@55[%
whitespace@57
end@58end
whitespace@61
tag_end@62%]
text@64\n\n
tag_start@66[%
whitespace@68
variable@69hello
variable apply@74(
squote string@75'World'
terminator@82)
whitespace@83
tag_end@85%]
text@87\n
tag_start@88[%
whitespace@90
variable@91hello
variable apply@96(
squote string@97'Badger'
terminator@105)
whitespace@106
tag_end@107%]
text@109\n
eof@110

Parse Tree

binary expr@9hello = block
variable element@3hello
=
block keyword@11block
Block
text@25\nHello
binary expr@40name or 'World'
variable element@35name
or
squote string element@43'World'
text@53!\n
text@64\n\n
sub keyword@74hello('World')
Call
variable element@69hello
Args
squote string element@75'World'
text@87\n
sub keyword@96hello('Badger')
Call
variable element@91hello
Args
squote string element@97'Badger'
text@109\n

Variables Used

hello
Uses
@ line 1[% hello = block(name) %]
@ line 5[% hello('World') %]
@ line 6[% hello('Badger') %]
name
Uses
@ line 2Hello [% name or 'World' %]!
@ line 1[% hello = block(name) %]

Generated Output

Hello World! Hello Badger!