At 9:22 AM on 30 Jul 2009, E R wrote: > 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.
If you have your compiled templates cached on disk (with the COMPILE_DIR
option), you can try this command:
perl -ne "while ( /\\\$stash->get\\(\\[?'(\w+)'/g ) { print \
qq/\$1\\n/ }" /path/to/cached_template_file|sort -u
I just quickly whipped that up based on the idea that every variable
lookup would compile to a $stash->get() call. It seems to work pretty
well... but I'll admit it's not exactly graceful. :-) And if there are
references to variables that don't result in a $stash->get call, those
would be missed.
--
C. Chad Wallace, B.Sc.
The Lodging Company
http://www.skihills.com/
OpenPGP Public Key ID: 0x262208A0
signature.asc
Description: PGP signature
_______________________________________________ templates mailing list [email protected] http://mail.template-toolkit.org/mailman/listinfo/templates
