TT3: /home/abw/web/london/tt3/slides/examples/html_menu.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[id="header"] ul[class="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@199[%
whitespace@201
html div@202div
construct list@205[
variable@206id
operator assign@208=
dquote@209"header"
terminator@217]
whitespace@218\n
html ul@224ul
construct list@226[
variable@227class
operator assign@232=
dquote@233"menu"
terminator@239]
whitespace@240 \n
command for@249for
whitespace@252
variable@253menu
whitespace@257\n
html li@267li
whitespace@269
html a@270a
construct list@271[
variable@272href
operator assign@276=
variable@277item
operator dot@281.
word@282link
terminator@286]
whitespace@287
variable@288item
operator dot@292.
word@293text
whitespace@297\n
tag_end@298%]
text@300\n
eof@301

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@202div
html keyword element@224ul
for keyword@249for
List
variable element@253menu
Then
html keyword element@267li
html keyword element@270a
binary expr@292item.text
variable element@288item
.
word element@293text
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>