We don't bite newbies here... much | |
PerlMonks |
Dynamic TMPL_INCLUDE in HTML::Templateby gryphon (Abbot) |
on May 03, 2002 at 16:52 UTC ( [id://163843]=perlquestion: print w/replies, xml ) | Need Help?? |
gryphon has asked for the wisdom of the Perl Monks concerning the following question: Greetings fellow monks, I've been using HTML::Template in combination with CGI::Application for a while now with much success and joy. However, I've recently come into a situation where I need some advice. I have a series of templates being used by a Web application which use HTML::Template's TMPL_INCLUDE tag to insert additional templates. I'm quickly running into a situation where I'm going to need to define the name of the included template in the Perl code of application module, not the template tag. For example, here's what I have right now:
And of course, the Perl code inside the CGI::Application-type screen handler subroutine looks something like this:
The problem is that now I need to have several "page_handler_type_*.tmpl" files, and I'll only know which one to include at run-time. What I'd really love to do is embed via TMPL_VAR the name of the to be included template file for the header inside the TMPL_INCLUDE tag, much like how you can embed TMPL_VAR tags inside any other HTML tag: <TMPL_INCLUDE name="<TMPL_VAR name="includeheadername">">Then I could just add "includeheadername" to the list of stuff sent to $tmpl_obj->param(), but that's not allowed. I could also construct the final page as page parts generated by multiple "$tmpl_obj"s inside the screen handler subroutine, but that starts to defeat the whole purpose of using HTML::Template in the first place. Any thoughts, suggestions, comments about how best to solve this dilema? -gryphon
Back to
Seekers of Perl Wisdom
|
|