On Thu, Feb 21, 2008 at 2:29 PM, Chad <[EMAIL PROTECTED]> wrote:
>
>  In your controller you are either setting c.layout_template ...

> .... Then you pass the layout
>  variable into an application template

>  ...I feel like an unfortunate downside of this approach
>  is having to include that conditional layout code in every template.

I've been thinking about your "problem" and my first reaction
was...what's wrong with xi:include?
It should be able to do whatever you need ... it might look verbose
but Genshi does not need to reparse the xml  everytime it runs.

Then I realized, I don't know your requirements specifically...i.e.
when exactly do you know you need the layout stuff added.  Also, your
aversion to including something in every template might be
unwarranted.  You already have to (I'm guessing) include the
master.html.  either include one more layout call or even place it in
the master itself.

OK. then I thought, maybe Chad is a pretty smart guy and knows all of
this.  Your posting could be a result of the real life condition that
the "layout" markup might need to do some real python processing.
Then you have a situation the xi:include does not handle in an obvious
manner.  If the needs are modest, you can use the Genshi code block
derective.

The final suggestion is that, if you know your layout needs at the
time of the routes proccessing (early on in the chain) then perhaps
the most solid solution is to use middleware.  Harder to configure:
yes. More advanced to even grok for a newcommer: yes. But in the end,
you can take full control over what gets rendered and the controller
need not concern itself at all with what the middleware does to it's
output.

Plus if you code up a layout solution as middleware to be like
sitemesh, you have a component that others can use, extend and support
and could be another pluggable component for the pylons framework.

--
Phil

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to