in reply to Import Constants From File to Templates?
OK if you don't need those constants at all ...
Instead of passing the exported constants each time with ->process
>
you could make your config module export the initialized TT object
package Sam::Constants; use Template; our $tt = Template->new( # export me { INCLUDE_PATH => $BASE_DIR . '/root/src/', INTERPOLATE => 1, CONSTANTS => { ... }, VARIABLES => { ... }, } ) || die "$Template::ERROR\n";
(see also Re: Import Constants From File to Templates?)
And if things like $BASE_DIR need to be flexible, provide an import() function.
use Sam::Constants base_dir => "...";
and if you have to manage different constructor setups, export functions which do the different construction and return the specialized $tt object.
package Sam::Constants; my @defaults_all = (... ); sub foo { return Template->new( @_ , @defaults_all, DEFAULTS_foo ) }; sub bar { return Template->new( @_ , @defaults_all, DEFAULTS_bar ) }; ... # other file use Sam::Constants qw/foo/; my $tt = foo(LOCAL_CFG); $tt->process();
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|