On 10/6/05, forgems <[EMAIL PROTECTED]> wrote:
>
> Hi i have a question regarding kid templates.
> Is it possible to set py:extends to some variable?. I want to have
> something like that.

Yes. py:extends can either be a string which points to the template
file in question, or it can be a python expression that gets evaluated
and is assumed to be a template module.

You could add something like this to controllers.py:

from turbogears import view
view.baseTemplates.append("PACKAGE.templates.templatename")

for each layout

Then, at the top of your template:
<?python
    layoutname = "PACKAGE.templates.%s" % (ChooseALayout())
    layout = __import__(layoutname, dict(), dict(), ["PACKAGE.templates"])
 ?>

And your extends can then just look like this;

py:extends="layout"

Hope this helps.
Kevin

Reply via email to