I'm gonna throw this out there:
Currently, say there are three templates "before", "do_my_loop" and "after".
file before:
-----------------------
blah blah blah [% USE some_magic_module %]
-----------------------
file do_my_loop:
----------------------
[% database.field_a %] [% database.field_b %] etc...
----------------------
file after:
----------------------
[% "Something else here..." %]
----------------------
Right now, all three files get globbed together to form a single template.
Now this works perfectly fine, except for the fact that "before" and "after"
have to be maintained in separate files. This is what the template looks
like when I glob them together just before processing:
Result from three files:
----------------------------------------------------------------------
blah blah blah [% USE some_magic_module %]
[%- FOREACH database = database_buffer %]
[% database.field_a %] [% database.field_b %] etc...
[%- END -%]
[% "Something else here..." %]
----------------------------------------------------------------------
The "foreach" in the resulting template handles the iteration through the
database_buffer list I'm sending to the template.
What I'm trying to do is give the user a good (read: "single") place to put
a "[% USE mycustomlibrary %]" in their file, but have it be in the same
physical file as the "do_my_loop" template, but without actually having the
processor execute the "USE" each time the do_my_loop is evaluated...
I would LOVE to have a template that looks like this instead:
----------------------------------------------------------------------------
--------
[% BLOCK before %]
blah blah blah [% USE some_magic_module %]
[% END %]
[% BLOCK do_my_loop %]
[% database.field_a %] [% database.field_b %] etc...
This will be evaluated by my program a billion times...
[% END %]
[% BLOCK after %]
[% "Something else here..." %]
[% END %]
----------------------------------------------------------------------------
--------
I was thinking that by getting access to the makeup of an unparsed "block"
from the toolkit would allow me to do what I want... Of course, I'm open to
any suggestions!
I could do multiple-passes over the template using different TAGS for the
before and after blocks and then somehow persist the stash between
passes.... That's the best I can come up with so far.
PRE and POST look like good candidates, but they still require separate
template files... Right?
Thank you for your time!
Bryan Shannon
Senior Applications Developer
Tribune Media Services
[EMAIL PROTECTED]
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates