The problem I want to solve is to be able to perform some static
analysis on my templates to make sure I haven't mis-typed variable
names, that my perl code is setting up the right stash variables, that
you've got documentation for all accessed variables, etc.

Extracting all the stash variable references is also handy tool to
help you understand what a template you've never seen before does. It
gives you an overview of all the information the template is dependent
on.

I'll look into modifying the compiler to save that information.
Alternatively I could write some PPI code to parse the generated perl.

On Thu, Jul 30, 2009 at 4:04 PM, Josh Rosenbaum<[email protected]> wrote:
> It's usually helpful to add what problem you are trying to solve as there
> may be more than one way to solve it.
>
> C. Chad Wallace's solution is probably close to what you want and may be
> your best bet.
>
> If you need this data at runtime and are ONLY looking for variables that
> have changed, you could do something creative with some perl blocks:
>
> [% PERL %]
> print $stash->_dump();
> [% END %]
>
> Another alternative would be overriding the Stash class to create a list of
> variables that can be displayed after the run. If you want to be able to
> check out variables accessed/wrote by other templates processed by the
> current one, I think you'd probably be stuck with doing it at runtime, since
> those templates usage can be dynamic.
>
> Finally, if you need it at compile time, maybe you could do something with
> the compilation process itself. That would appear to require
> Template::Directive hacking, but I could be wrong.
>
> -- Josh
>
> E R wrote:
>>
>> Hi,
>>
>> After compiling a template, Is there a way to get a list of all
>> variables that it references?
>> It seems that this is something the compiler could keep track of if it
>> doesn't already.
>
>

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to