[Templates] how do I find all parsed tags?
Blue Eyed Devil
eyed_devil_blue at hotmail.com
Mon Jun 30 16:31:31 BST 2008
Hi,
I was taking apart the code of Template Toolkit because I tried to figure out if TT keeps a record of all parsed tags (params/vars/directives), and unfortunately it doesn't seem like it does. I could very easily hack the code but in my project my goal is to use TT as-is and try to get out of it what I need. So no hacking of the code is an option.
This is what I found:
Template/Parser.pm parses the tags (directives) and then it more or less builds a block for the directive. The tags however are then localised in Service.pm (in process()) and delocalised so the Stash changes, effectively losing any reference to any of the processed tags by the time you want to use it from the outside.
My other problem is that even if it wouldn't delocalise the vars the Stash only keeps a record of the passed vars, and not all the tags it was able to parse.
My question is whether or not TT has an option to know all the tags it was able to parse and retrieve those?
Example:
[% BOY %] says [% WORD %] to [% GIRL %]
Let's say I pass in the vars, BOY and WORD to $template->process() but NOT the var GIRL. However, I would like to have the ability to do something like:
@tags = $template->some_method();
And when I would go through the @tags it would contain ('BOY', 'WORD', 'GIRL').
Logically it should be called after $template->process() to be able to get all tags.
Any ideas on how to implement this with TT without any hacking?
Thanks.
Milan
_________________________________________________________________
Introducing Live Search cashback . It's search that pays you back!
http://search.live.com/cashback/?&pkw=form=MIJAAF/publ=HMTGL/crea=introsrchcashback
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.template-toolkit.org/pipermail/templates/attachments/20080630/a706bb8a/attachment.htm
More information about the templates
mailing list