Hi there,

On Thu, May 21, 2009 at 9:28 AM, Andy Chu <[email protected]> wrote:
> Hm, can this be done by modifying the data dictionary?  I think that
> was my original suggestion.  Like:
>
> def AddPathInfo(data_dict):
>  for each compound object:
>    AddPathInfo(...) # recursively

Sure, that's an alternative way to generate the paths and might in
fact be prettier. I hooked it into ScopedContext as that seemed a
fairly natural fit, but this would work just fine as well.

The important new insight I had however are about the hook points and
a way to make this work completely transparently without requiring
anyone to modify their templates (as long as some easy structural
constraints concerning HTML generation are followed). I propose a
beforeSection and beforeRepeatedSection hook point. Perhaps we also
need the after* equivalent, and I'm not sure I got everything right
concerning alternates and or and so on, so a review would be
appreciated. I also want to be able to *test* these hooks.

> Actually the other bug about Template not being prototypable is
> relevant here.

Yes, that would allow the data dictionary modification to be
implemented fairly cleanly, though an alternative would be to insert a
similar hook to pre-process the JSON structure.

Subclassing won't help though with _DoSection and _DoRepeatedSection,
where I need to pass in my hooks. See the patch.

> I think this would fit well in an add-on module, and I
> was thinking about adding it but never got around to it.  There are a
> few things like this that you might want to do with the data
> dictionary.

Yes, that would be useful, and it could contain the path resolution
mechanism as well, along with functionality that finds the <div />
marker in HTML and the hooks that automatically insert it.

My concrete questions:

* please review the hooks. Ignore the path story for now, I just want
hooks to insert into the stream whenever any {.command} changes the
scope (or when one leaves a scope with {.end}, though this is less
important).

* how would I set up the javascript tests to set up with hooks?

Regards,

Martijn

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