List Info

Thread: nested wrappers and variables




nested wrappers and variables
user name
2006-06-07 22:09:34
I managed to get this to work by using INCLUDE and BLOCK
rather than
WRAPPER:

base:
[% IF template.name.match('/') -%]
  [%- DEFAULT section = template.name.replace('/.*','')
-%]
[% END -%]
<html>
<body>
[% INCLUDE contents %]
...

page:
[% INCLUDE base %]
[% BLOCK contents %]
<h1>Section: [% section %]</h1>
[% INCLUDE content %]
[% END -%]
...

foo.tt2:
[% INCLUDE page -%]
[% BLOCK content -%]
My content here...
[% END -%]

It works, but it seems pretty convoluted to me, and I have
to use different
block names for the different levels of inclusion.

Is my brain completely inside out on this one, or is there
some clear
explanation for why variables set in a wrapper aren't
available to the
template that uses the wrapper?

Thanks!

Dustin 

-----Original Message-----
From: templates-admintemplate-toolkit.org
[mailto:templates-admintemplate-toolkit.org] On Behalf Of Dustin
Frazier
Sent: Wednesday, June 7, 2006 1:28 PM
To: templatestemplate-toolkit.org
Subject: [Templates] nested wrappers and variables

I have a common page template for all pages that starts like
this:

base:
[% IF template.name.match('/') -%]
  [%- DEFAULT section = template.name.replace('/.*','')
-%] [% END -%] ...

I then have a second, more specific template that is based
on this one:

page:
[% WRAPPER base %]
...

If I try to reference the variable 'section' within a page
that uses the
'page' wrapper, it's not defined.  Is there something
special I need to do
from one wrapper template or the other to make this work?  I
don't want to
duplicate all of the stuff at the top of my base template
within the page
template (code sharing being the whole point of having one
based on the
other).

Thanks!

Dustin



_______________________________________________
templates mailing list
templatestemplate-toolkit.org
http://lists.template-toolkit.org/mailman/listinfo/t
emplates



_______________________________________________
templates mailing list
templatestemplate-toolkit.org
http://lists.template-toolkit.org/mailman/listinfo/t
emplates
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )