Dynamic includes in Template::Toolkitby Molt (Chaplain)
|on May 07, 2003 at 10:58 UTC||Need Help??|
Molt has asked for the
wisdom of the Perl Monks concerning the following question:
I'm currently working on a web application using Template Toolkit, but now I'm experiencing difficulties trying to work out the nicest way to allow dynamic includes.
What I'm trying to do is have a template including other templates dynamically based on either the status of a variable, or the result of a function, so that the following could be made to work. Please note I do know that the 'header' and 'body' in the includes are taken as literals, it's this I'm trying to get round here.
As part of program:
The aim of this is to allow me to associate new actions to page contents without a change either to the basic code, or to the top-level page templates.
I could code up a plugin to do this, but fear reinventing wheels. Any hints?