Open GoogleCodeExporter opened 9 years ago
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.
Original comment by nadir.se...@gmail.com
on 19 May 2009 at 4:19
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.
Original comment by gtempacc...@yahoo.com
on 19 May 2009 at 4:04
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.
Original comment by gtempacc...@yahoo.com
on 14 Nov 2009 at 8:53
Original issue reported on code.google.com by
gtempacc...@yahoo.com
on 10 Apr 2009 at 12:34