George Moschovitis
unread,Aug 13, 2010, 7:32:05 AM8/13/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Normal-Template
I am copying the answer to a question that may be useful to others.
QUESTION:
...
i wasn't able to figure out how to iterate through a deep hierarchy of
elements. for example, given this data:
var data = {
ul: [
'List Item 1',
'List Item 2',
[
'List Item 3.1',
'List Item 3.2'
]
]
};
or this:
data.ul=[
{value:'List Item 1'},
{value:'List Item 2'},
{values:
[
{value: 'List Item 3.1'},
{value: 'List Item 3.2'}
]
}
];
how can i get this?
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>
<ul>
<li>Item 3.1</li>
<li>Item 3.2</li>
</ul>
</li>
</ul>
ANSWER:
Try this:
var data = {
items: [
{title: "item 1"},
{title: "item 2"},
{title: "item 3", items: [
{title: "item 3.1"},
{title: "item 3.2"}
]},
{title: "item 4"}
]
}
<ul>
{:r items}
<li>
{=title}
{:if children}
<ul>
{:r items}
<li>{=title}</li>
{/:r}
</ul>
{/:if}
</li>
{/:r}
</ul>
-g.