I just skimmed thru the docs and found two possible approaches:
my $tt = Template->new({ VARIABLES => { version => 3.14, release => 'Sahara', }, }); my $vars = { serial_no => 271828, }; $tt->process('myfile', $vars);
my $tt = Template->new({ CONSTANTS => { version => 3.14, release => 'skyrocket', col => { back => '#ffffff', fore => '#000000', }, myobj => My::Object->new(), mysub => sub { ... }, joint => ', ', }, });
Hence you could write a sub current_constants() which is introspecting your current package and return a list of pairs which maps each constant to it's name. Another way could be to check the exporter settings of the defining package.
my $tt = Template->new({ CONSTANTS => { current_constants() }, });
Once this works you should also be able to write a TT plugin to do this automatically.
Question That's what you want?
°) this was written before the OP added his "EDIT" section.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
In reply to Re: Import Constants From File to Templates?
by LanX
in thread Import Constants From File to Templates?
by varanasi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |