Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:
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
<tmpl_if name="foonav"> <tmpl_include name="foo-nav.inc"> </tmpl_if>
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.<tmpl_if name="foonav"> <tmpl_include name="foo-nav.inc"> </tmpl_if> <tmpl_if name="barnav"> <tmpl_include name="bar-nav.inc"> </tmpl_if>
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')
=~y~b-v~a-z~s; print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Two questions about HTML::Template
by tinita (Parson) on Jun 23, 2006 at 11:35 UTC | |
|
Re: Two questions about HTML::Template
by wfsp (Abbot) on Jun 23, 2006 at 11:29 UTC | |
|
Re: Two questions about HTML::Template
by rhesa (Vicar) on Jun 23, 2006 at 13:17 UTC | |
|
Re: Two questions about HTML::Template
by cees (Curate) on Jun 23, 2006 at 15:31 UTC | |
by Cody Pendant (Prior) on Jun 23, 2006 at 21:17 UTC | |
by bradcathey (Prior) on Jun 10, 2007 at 00:49 UTC |