> OK, I like that, with one refinement. ".if" is just a syntactic
> shortcut for for ".section @". So these are the same:
I unfortunately had to implement most of this to realize it doesn't
work. The reason: it's confusing an ambiguous what context the
clauses get run in.
{section num singular?} effectively encompasses 2 predicates and one
side effect:
* bool(context.num)
* push into num if the above is true
* singular?(context.num)
So it's just too confusing to write the clauses to take care of the
cases where 'num' exists but is not singular, where 'num' doesn't
exist, where 'num' exists but is "falsey".
So I think predicates will just remain entirely separate from
sections. I am leaning towards the {.if pred?} ... {.or pred?}
{.end} syntax. What's there is cleaner, but it doesn't allow nesting
of predicates.
On the other hand, I'm not sure you really need nesting of predicates
-- a flat list should suffice in any case I can think of. Perhaps
that is an incentive to avoid putting business logic in predicates.
Another option is:
{.if singular?}
one
{.plural?} # No .or
many
{.or}
none
{.end}
I think that reads better actually.
Andy
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---