Mark, many thanks. Wow!

I've gone over this several times.   Learned a number of things in the
process.  

Again, thanks.  Eric.

> If you want to do is to have the same global configuration variables
> available in all your
> templates you use with CGI::Application, you might want to override the
> default load_tmpl() function to do that for you.

>Something like this:
> 
> sub load_tmpl {
> my $self = shift;
> my ($tmpl_file, @extra_params) = @_;
> 
> my $fq_tmpl_file = $self->tmpl_path() . $tmpl_file;
> 
> require HTML::Template;

> # set up the templates with some defaults
> # %CFG is global config hash
> # this key is a reference to hash of HTML::Template defaults
> # including die_on_bad_params=>0


> my $t = HTML::Template->new_file($fq_tmpl_file, @extra_params, %{
> $CFG{HTML_TMPL_DEFAULTS} });

> 
> # supply global config variables to the templates. Rather than pollute
> the name space

yes. 

> # let's prefix them with cfg_.
> $t->param(
> map {
> my $k = $_;
> 'CFG_'.$k =>  $CFG{$k};
> } keys (%CFG)
> );

> return $t;
> }
> 
>


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to