RE: [htmltmpl] placing .tmpl files in a subdirectory?
Brought to you by:
samtregar
|
From: Roy R. <ro...@ir...> - 2002-07-02 21:47:20
|
> Greets Folks,
>
> Does anyone here place their .tmpl files in a special
> directory assigned just for templates, like maybe:
>
> /cgi-bin/templates
>
> I was thinking of doing this for organizational
> purposes, but I wasn't sure of what problems I might
> run into, or what path I would have to use in the CGI
> programs, etc...
>
> Any advice appreciated.
>
> Thanks,
>
> Will
We usually separate the template names and location to a configuration file,
which the designers can update on their own. It look something like this:
TemplateConfig.pm
==================
package TemplateConfig;
use vars '$AUTOLOAD';
sub new {
my $class = shift;
bless {
_base_template_path => '/path/to/files/templates',
_add_rec => 'emp_add.html',
_delete_rec => 'emp_delete.html',
_edit_rec => 'emp_edit.html'
}, $class;
}
sub AUTOLOAD
{
my ($self) = @_;
$AUTOLOAD =~ /.*::get(_\w+)/;
exists $self->{$1};
return $self->{$1};
}
1;
In the cgi script, the package is instantiated and the file names are used
in the following format:
use TemplateConfig;
$config = TemplateConfig->new();
$filename = $config->get_base_template_path . $config->get_add_rec
Roy
ro...@ir...
|