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

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@3HTML_CMDS
whitespace@12
variable@13div
whitespace@16
variable@17ul
whitespace@19
variable@20li
whitespace@22
variable@23a
whitespace@24
tag_end@25?]
text@27\n\n
tag_start@29[%
whitespace@31
variable@32menu
whitespace@36
operator assign@37=
whitespace@38
construct list@39[
whitespace@40\n
construct hash@46{
whitespace@47
variable@48text
whitespace@52
operator pair@53=>
whitespace@55
squote string@56'One'
separator@61,
whitespace@62
variable@65link
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@96text
whitespace@100
operator pair@101=>
whitespace@103
squote string@104'Two'
separator@109,
whitespace@110
variable@113link
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@144text
whitespace@148
operator pair@149=>
whitespace@151
squote string@152'Three'
separator@159,
whitespace@160
variable@161link
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@197div
fragment@200#
word@201header
whitespace@207\n
html ul@213ul
operator dot@215.
word@216menu
whitespace@220 \n
command for@229for
whitespace@232
variable@233menu
whitespace@237\n
html li@247li
whitespace@249
html a@250a
construct list@251[
variable@252href
operator assign@256=
variable@257item
operator dot@261.
word@262link
terminator@266]
whitespace@267
variable@268item
operator dot@272.
word@273text
whitespace@277\n
tag_end@278%]
text@280\n
eof@281

Parse Tree

text@27\n\n
binary expr@37menu = [ { text => 'One'; link => 'one.html' }; { text => 'Two'; link => 'two.html' }; { text => 'Three'; link => 'three.html' } ]
variable element@32menu
=
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@53text => 'One'
word element@48text
=>
squote string element@56'One'
binary pair expr@70link => 'one.html'
word element@65link
=>
squote string element@73'one.html'
}
hash expr@94{ text => 'Two'; link => 'two.html' }
{
binary pair expr@101text => 'Two'
word element@96text
=>
squote string element@104'Two'
binary pair expr@118link => 'two.html'
word element@113link
=>
squote string element@121'two.html'
}
hash expr@142{ text => 'Three'; link => 'three.html' }
{
binary pair expr@149text => 'Three'
word element@144text
=>
squote string element@152'Three'
binary pair expr@166link => 'three.html'
word element@161link
=>
squote string element@169'three.html'
}
]
text@192\n\n
html keyword element@197div
html keyword element@213ul
for keyword@229for
List
variable element@233menu
Then
html keyword element@247li
html keyword element@250a
binary expr@272item.text
variable element@268item
.
word element@273text
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>