On Wed, Sep 30, 2009 at 8:16 PM, Andy Chu <[email protected]> wrote:
> On Wed, Sep 30, 2009 at 1:33 PM, Steven Roussey <[email protected]> wrote:
>>
>>> {num|plural? data datum}
>>>
>>> --> "datum" if num = 1
>>> --> "data" if num > 1
>>>
>>> But what if you want spaces in your arguments?  It lets you do this:
>>>
>>> {num|plural?.there are many.there is one}
>>>
>>> The first character after "plural?" is the argument separator now.
>>> This is like sed/perl: you can do s/foo/bar, or you can do
>>> s.this/has/slashes/.replacement.string.too.
>>>
>>> This isn't a huge deal, but I would want to have this flexibility,
>>> especially since it doesn't cost anything.
>>
>> Yes, the _CALL_RE should have \b to break from the name and the
>> arguments. I currently trim, but it is not a big deal to not do it.
>>
>>> How about I generate some cross-language tests and do it in Python,
>>> and do you want to follow up with JavaScript and/or PHP?
>>
>> Sounds good.
>>
>>> And what do you think about {.moderator?} vs {.if moderator} ?
>>
>> I like that things that start with a . are part of the language only.
>>
>>> The chaining is important.  Either of these looks wrong:
>>>
>>> {.if singular}
>>>     there is one
>>> {.else}
>>>     {.if plural}
>>>         there are many
>>>     {.else}
>>>         there are None
>>>     {.end}
>>> {.end}
>>>
>>> (Too ugly, bad indentation)
>>>
>>> {.if singular}
>>>     there is one
>>> {.if plural}  <-- this would be normally be elif
>>>     there is one
>>> {.else}
>>>     there are none
>>> {.end}
>>>
>>> (Not what you expect of if/else/end)
>>>
>>> Instead this looks cleanest to me:
>>>
>>> {.singular?}
>>>     there is one
>>> {.plural?}
>>>     there are many
>>> {.or}
>>>     there are None
>>> {.end}
>>
>>
>> I was working on doing this:
>>
>> {.if singular}
>>    there is one
>> {.or plural}
>>    there are many
>> {.or}
>>    there are None
>> {.end}

OK, I like that, with one refinement.  ".if" is just a syntactic
shortcut for for ".section @".  So these are the same:

{.section @ singular?}  # Optional second argument is a predicate
  one
{.or plural?}
  many
{.or}
  none
{.end}

{.if singular?}
  one
{.or plural?}
  many
{.or}
  none
{.end}

This will make the implemention simpler than what I put there for
Python.  It will extend well to formatters on sections too.

Repeated sections don't get predicates.  Sections and repeated
sections will diverge a bit, which I think is good.

thanks,
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to