Hey-
I've looked over recent threads on this list, but haven't seen this
covered. Please redirect me if it has been discussed before.
I'd like to be able to use the "repeated" directive to iterate over
object members (in JSON terms).
It seems to me like you force duplication of data if you only allow
iteration over array elements.
For example, if I wanted to have a template that both created a list of
links:
{.section pages)
Menu:
<ul>
{.repeated section @}
<li><a href="{[email protected]}">@.title</a></li>
{.end}
</ul>
{.end}
and had inline links to specific pages:
Link to page <a href="{page0.url}">{page0.title}</a>.
I would have to create a "data dictionary" that looked something like
the following:
{
"pages": [{
"title": "zero",
"url": "foo"
}, {
"title": "one",
"url": "bar"
}],
"page0": {
"title": "zero",
"url": "foo"
},
"page1": {
"title": "one",
"url": "bar"
}
}
Alternatively, if the template language allowed for iteration over
object members (and allowed for named repeat variables), then my menu
would look something like:
{.section pages}
Menu:
<ul>
{.repeated title @}
<li><a href="@.url">{title}</a>
{.end}
</ul>
{.end}
and my inline link would look like:
Link to page <a href="page.zero.url">zero</a>.
Most importantly, my "data dictionary" would collapse to simply:
{
"pages": {
"zero": {"url": "foo"},
"one": {"url": "bar"}
}
}
If this is something that is not already handled in a different way, I
think it could be implemented in a mostly backwards compatible way
(breaking where templates use substitution for a variable named "section").
If this email doesn't make any sense, I could rephrase it by starting
with the collapsed data dictionary and asking "how can I create a list
of links from this (and allow for deep linking without data duplication)?"
Thanks,
Tim
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JSON
Template" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/json-template?hl=en
-~----------~----~----~----~------~----~------~--~---