Don't ask to ask, just ask | |
PerlMonks |
Two questions about HTML::Templateby Cody Pendant (Prior) |
on Jun 23, 2006 at 10:55 UTC ( [id://557138]=perlquestion: print w/replies, xml ) | Need Help?? |
Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:
I'm working on a site where a URL calls a different template depending on where it's been called from.
For instance if the script gets called at myserver.com/foo/ then the script parses the path and uses the template "foo.tmpl". If it's in myserver.com/bar/ it uses the template "bar.tmpl" and so on. I'd like to go one further -- I'd like "foo.tmpl" to include a file: <tmpl_include name="foo.inc"> and "bar.tmpl" to include a different file <tmpl_include name="bar.inc">. Is there any way to do this? The obvious way to do it is something like, create a variable $foonav and pass it to the template and have
And so on for a bunch of other variables. But that feels pretty kludgy. And which brings me to my second question, why, when I do this: Does it cause the following error message: HTML::Template->new() : Cannot open included file /path/to/foo-nav.inc : file not found. at /usr/share/perl/5.8/HTML/Template.pm line 2241. Even when I haven't ever called on "bar-nav.inc"? No matter whether the variable is passed to grab the include, I get the error. I'm busy developing and haven't created the file yet. It somehow seems inefficient for HTML::Template to be checking the existence of files when it doesn't need to. Can I tell it not to? ($_='kkvvttuu bbooppuuiiffss qqffssmm iibbddllffss')
Back to
Seekers of Perl Wisdom
|
|