TT3: /home/abw/web/london/tt3/slides/examples/html_menu2.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
#
header
ul
.
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
@194
[%
whitespace
@196
html div
@197
div
fragment
@200
#
word
@201
header
whitespace
@207
\n
html ul
@213
ul
operator dot
@215
.
word
@216
menu
whitespace
@220
\n
command for
@229
for
whitespace
@232
variable
@233
menu
whitespace
@237
\n
html li
@247
li
whitespace
@249
html a
@250
a
construct list
@251
[
variable
@252
href
operator assign
@256
=
variable
@257
item
operator dot
@261
.
word
@262
link
terminator
@266
]
whitespace
@267
variable
@268
item
operator dot
@272
.
word
@273
text
whitespace
@277
\n
tag_end
@278
%]
text
@280
\n
eof
@281
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
@197
div
html keyword element
@213
ul
for keyword
@229
for
List
variable element
@233
menu
Then
html keyword element
@247
li
html keyword element
@250
a
binary expr
@272
item.text
variable element
@268
item
.
word element
@273
text
text
@280
\n
Variables Used
href
Uses
@ line 13
li a[
href
=item.link] item.text
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>