On Tue, May 26, 2009 at 5:18 AM, Martijn Faassen <[email protected]> wrote:
>
> Hey,
>
> On Tue, May 26, 2009 at 1:02 AM, Andy Chu <[email protected]> wrote:
>>
>> On Mon, May 25, 2009 at 1:29 PM, Martijn Faassen <[email protected]>
>> wrote:
>> I think you're trying to avoid duplicating information in both the
>> data dictionary (a JSON tree) and the template string (HTML DOM tree).
>> But this seems like a convoluted way to do it.
>>
>> How would you do this if you were using another template engine? e.g.
>>
>> http://code.google.com/p/google-jstemplate/
>> http://beebole.com/pure/
>
> I don't know, I haven't looked these template engines. In case they
> can't do what I want, should json-template be restricted to what these
> languages can do? I'm trying to be creative here. :)
>
>> These systems actually assume you're generating HTML; JSON Template is
>> for generic text and thus has no knowledge of the output.
>
> I know that, but it also has support for HTML output, and that's what
> I care about. That doesn't mean I want to stop anyone else from doing
> something else; I just want it to support what I want to do. I'm
> obviously exploring patterns and ideas here.
It's definitely good to explore ideas, but comparisons with other
template engines are useful. If no other template engine has a
feature, then it's a good indication that users aren't running into
the problem generally.
>> From what you're saying, a template preprocessor shouldn't be ruled
>> out as a solution. The language was designed to be trivially parsed
>> (it can be split into tokens with a single regex.split() call).
>
> Sure, a preprocessor would work too. In fact it'd be possible to
> change the compilation process too to insert the fragments whenever a
> {.directive} is used; I think that could lead to a pretty clean API.
I'll have to think about the rest of this a bit more, but you should
think about whether you want to hook into the template compilation
process or the expansion process. They are very separate -- a
template can be compiled once and expanded many times with different
data dictionaries.
Without seeing the example I can't see which one fits the problem. I
think you initially asked about the expansion process. But if it can
be done with a preprocessor, without a data dictionary, then that
means it fits in the compilation process.
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
-~----------~----~----~----~------~----~------~--~---