I've been banging my head against this for at least six hours, and I'm
no closer to figuring out a decent solution than when I started.
I'd like to have a pair of tags, such that the tag which appears
earlier in the page can change depending on the values of later tags.
So if I have the following:
---
{{ my_summary() }}
... arbitrary HTML ...
{{ my_values('Tom', 'Dick', 'Harry') }}
... arbitrary HTML ...
{{ my_values('Fred', 'Barney') }}
---
I'd end up with the following:
---
This page includes information about <b>Tom</b>, <b>Dick</b>,
<b>Harry</b>, <b>Fred</b>, and <b>Barney</b>.
... arbitrary HTML ...
<h1>Tom, Dick, and Harry</h1>
... arbitrary HTML ...
<h1>Fred and Barney</h1>
---
It needs to take into account tags in includes and imports, as well,
which is what makes it difficult. I first thought I could write a tag
that set a variable on the context which other tags could assign into,
but there doesn't seem to be a way to defer rendering of the tag until
after the rest of the tags are rendered. I can't scan the token
stream in the parsing step, because included templates aren't being
parsed in the same step. I can't have the children set a value in a
global variable during the parsing, which the parent uses during
rendering, because I can't see a way to tell which templates are
included in which template from either step.
All I can think to do is wrap the render() step. Before the
rendering, I'd add a list to the context. During the rendering, I'd
populate the list, and have the first tag write a special string (like
"MY_SUMMARY_HERE") into the resulting HTML. After the rendering, I'd
search and replace the special string with my own. I'm not even sure
this will work.
Isn't there a better way of doing this? Surely?
-- Chris
It would be easy if there were some kind of LazyNode which the parser
would defer evaluating
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pocoo-libs" 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/pocoo-libs?hl=en
-~----------~----~----~----~------~----~------~--~---