TT3: /home/abw/web/london/tt3/slides/examples/block_sub.tt3
Source
Tokens
Tree
Variables
Output
Template Source
[%
hello
=
block
(
name
)
%]
Hello
[%
name
or
'World'
%]
!
[%
end
%]
[%
hello
(
'World'
)
%]
[%
hello
(
'Badger'
)
%]
--EOF--
Source Tokens
tag_start
@0
[%
whitespace
@2
variable
@3
hello
whitespace
@8
operator assign
@9
=
whitespace
@10
command block
@11
block
construct parens
@16
(
variable
@17
name
terminator
@21
)
whitespace
@22
tag_end
@23
%]
text
@25
\nHello
tag_start
@32
[%
whitespace
@34
variable
@35
name
whitespace
@39
binary operator
@40
or
whitespace
@42
squote string
@43
'World'
whitespace
@50
tag_end
@51
%]
text
@53
!\n
tag_start
@55
[%
whitespace
@57
end
@58
end
whitespace
@61
tag_end
@62
%]
text
@64
\n\n
tag_start
@66
[%
whitespace
@68
variable
@69
hello
variable apply
@74
(
squote string
@75
'World'
terminator
@82
)
whitespace
@83
tag_end
@85
%]
text
@87
\n
tag_start
@88
[%
whitespace
@90
variable
@91
hello
variable apply
@96
(
squote string
@97
'Badger'
terminator
@105
)
whitespace
@106
tag_end
@107
%]
text
@109
\n
eof
@110
Parse Tree
binary expr
@9
hello = block
variable element
@3
hello
=
block keyword
@11
block
Block
text
@25
\nHello
binary expr
@40
name or 'World'
variable element
@35
name
or
squote string element
@43
'World'
text
@53
!\n
text
@64
\n\n
sub keyword
@74
hello('World')
Call
variable element
@69
hello
Args
squote string element
@75
'World'
text
@87
\n
sub keyword
@96
hello('Badger')
Call
variable element
@91
hello
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 2
Hello [%
name
or 'World' %]!
@ line 1
[% hello = block(
name
) %]
Generated Output
Hello World! Hello Badger!