| Issue 13: | ".repeated" is not strictly necessary | |
| 2 people starred this issue and may be notified of changes. | Back to list |
Proposal:
{.section} will be augmented to repeat if the node type is a list [].
{.repeated section} will then become superfluous. But for readability,
we'll keep it, and it could *enforce* that the node type is a list, unlike
{.section}.
May 19, 2009
That's true, but with the suggestion your examples wouldn't change. All that would
happen is that you can omit {.repeated section @} from your templates and instead
include {.section @}. Since 'functions' and 'classes' are lists, it would know how
to do the right thing.
That said, as mentioned I don't think the template is any more readable this way.
But it would be optional.
Nov 14, 2009
If we end up doing issue 34, then this is not as compelling. In that case {.section} on a dictionary and {.repeated section} will mean totally different things. Right now {.repeated section} is idiomic on an array but {.section} can actually also be used. So I prefer to keep this distinction: foo: [1,2,3,4] {.section foo} Here is a list of integers joined by commas {@|join ,} {.or} No integers {.end} So actually this should probably be rejected. repeated section stays distinct.
Labels:
-Type-Defect -Priority-Medium Type-Other Priority-Low
|
I don't think this is a good idea, it completely breaks a reasonable use case in json-template which I am using myself quite a lot. {{{ var jsonA = { functions: [ { name: "Foo" }, { name: "Bar" }, { baz: "Baz" } ], classes: [ { name: "Foo" }, { name: "Bar" }, { baz: "Baz" } ] }; var jsonB = { functions: [ { name: "Foo" }, { name: "Bar" }, { baz: "Baz" } ] }; var jsonC = { classes: [ { name: "Foo" }, { name: "Bar" }, { baz: "Baz" } ] }; var jsonD = {}; }}} {{{ {.section functions} <h2>Functions</h2> <ul> {.repeated section @} <li>{name|html}</li> {.end} </ul> {.end} {.section classes} <h2>Classes</h2> <ul> {.repeated section @} <li>{name|html}</li> {.end} </ul> {.end} }}} If you use jsonA a list of functions and classes are shown; jsonB just the functions; jsonC just the Classes; jsonD neither.