TT3: /home/abw/web/london/tt3/slides/examples/html_menu.tt3
Source
Tokens
Tree
Variables
Output
Template Source
[?
HTML_CMDS
div
ul
li
a
?]
[%
menu
=
[
{
text
=>
'One'
,
link
=>
'one.html'
}
,
{
text
=>
'Two'
,
link
=>
'two.html'
}
,
{
text
=>
'Three'
,
link
=>
'three.html'
}
,
]
%]
[%
div
[
id
=
"header"
]
ul
[
class
=
"menu"
]
for
menu
li
a
[
href
=
item
.
link
]
item
.
text
%]
--EOF--
Source Tokens
tag_start
@0
[?
whitespace
@2
control htmlcmds
@3
HTML_CMDS
whitespace
@12
variable
@13
div
whitespace
@16
variable
@17
ul
whitespace
@19
variable
@20
li
whitespace
@22
variable
@23
a
whitespace
@24
tag_end
@25
?]
text
@27
\n\n
tag_start
@29
[%
whitespace
@31
variable
@32
menu
whitespace
@36
operator assign
@37
=
whitespace
@38
construct list
@39
[
whitespace
@40
\n
construct hash
@46
{
whitespace
@47
variable
@48
text
whitespace
@52
operator pair
@53
=>
whitespace
@55
squote string
@56
'One'
separator
@61
,
whitespace
@62
variable
@65
link
whitespace
@69
operator pair
@70
=>
whitespace
@72
squote string
@73
'one.html'
whitespace
@83
terminator
@86
}
separator
@87
,
whitespace
@88
\n
construct hash
@94
{
whitespace
@95
variable
@96
text
whitespace
@100
operator pair
@101
=>
whitespace
@103
squote string
@104
'Two'
separator
@109
,
whitespace
@110
variable
@113
link
whitespace
@117
operator pair
@118
=>
whitespace
@120
squote string
@121
'two.html'
whitespace
@131
terminator
@134
}
separator
@135
,
whitespace
@136
\n
construct hash
@142
{
whitespace
@143
variable
@144
text
whitespace
@148
operator pair
@149
=>
whitespace
@151
squote string
@152
'Three'
separator
@159
,
whitespace
@160
variable
@161
link
whitespace
@165
operator pair
@166
=>
whitespace
@168
squote string
@169
'three.html'
whitespace
@181
terminator
@182
}
separator
@183
,
whitespace
@184
\n
terminator
@188
]
whitespace
@189
\n
tag_end
@190
%]
text
@192
\n \n
tag_start
@199
[%
whitespace
@201
html div
@202
div
construct list
@205
[
variable
@206
id
operator assign
@208
=
dquote
@209
"header"
terminator
@217
]
whitespace
@218
\n
html ul
@224
ul
construct list
@226
[
variable
@227
class
operator assign
@232
=
dquote
@233
"menu"
terminator
@239
]
whitespace
@240
\n
command for
@249
for
whitespace
@252
variable
@253
menu
whitespace
@257
\n
html li
@267
li
whitespace
@269
html a
@270
a
construct list
@271
[
variable
@272
href
operator assign
@276
=
variable
@277
item
operator dot
@281
.
word
@282
link
terminator
@286
]
whitespace
@287
variable
@288
item
operator dot
@292
.
word
@293
text
whitespace
@297
\n
tag_end
@298
%]
text
@300
\n
eof
@301
Parse Tree
text
@27
\n\n
binary expr
@37
menu = [ { text => 'One'; link => 'one.html' }; { text => 'Two'; link => 'two.html' }; { text => 'Three'; link => 'three.html' } ]
variable element
@32
menu
=
list expr
@39
[ { text => 'One'; link => 'one.html' }; { text => 'Two'; link => 'two.html' }; { text => 'Three'; link => 'three.html' } ]
[
hash expr
@46
{ text => 'One'; link => 'one.html' }
{
binary pair expr
@53
text => 'One'
word element
@48
text
=>
squote string element
@56
'One'
binary pair expr
@70
link => 'one.html'
word element
@65
link
=>
squote string element
@73
'one.html'
}
hash expr
@94
{ text => 'Two'; link => 'two.html' }
{
binary pair expr
@101
text => 'Two'
word element
@96
text
=>
squote string element
@104
'Two'
binary pair expr
@118
link => 'two.html'
word element
@113
link
=>
squote string element
@121
'two.html'
}
hash expr
@142
{ text => 'Three'; link => 'three.html' }
{
binary pair expr
@149
text => 'Three'
word element
@144
text
=>
squote string element
@152
'Three'
binary pair expr
@166
link => 'three.html'
word element
@161
link
=>
squote string element
@169
'three.html'
}
]
text
@192
\n \n
html keyword element
@202
div
html keyword element
@224
ul
for keyword
@249
for
List
variable element
@253
menu
Then
html keyword element
@267
li
html keyword element
@270
a
binary expr
@292
item.text
variable element
@288
item
.
word element
@293
text
text
@300
\n
Variables Used
class
Uses
@ line 11
ul[
class
="menu"]
href
Uses
@ line 13
li a[
href
=item.link] item.text
id
Uses
@ line 10
[% div[
id
="header"]
item
Uses
@ line 13
li a[href=item.link]
item
.text
@ line 13
li a[href=
item
.link] item.text
Vars
link
Uses
@ line 13
li a[href=
item.link
] item.text
text
Uses
@ line 13
li a[href=item.link]
item.text
link
Uses
@ line 4
{ text => 'One',
link
=> 'one.html' },
@ line 5
{ text => 'Two',
link
=> 'two.html' },
@ line 6
{ text => 'Three',
link
=> 'three.html' },
menu
Uses
@ line 3
[%
menu
= [
@ line 12
for
menu
text
Uses
@ line 4
{
text
=> 'One', link => 'one.html' },
@ line 5
{
text
=> 'Two', link => 'two.html' },
@ line 6
{
text
=> 'Three', link => 'three.html' },
Generated Output
<div id="header"><ul class="menu"><li><a href="one.html">One</a></li><li><a href="two.html">Two</a></li><li><a href="three.html">Three</a></li></ul></div>