Chad wrote: > Interesting.. Let me see if I have this right. > > In your controller you are either setting c.layout_template if you > want to use a layout or None if you don't.. Then you pass the layout > variable into an application template and conditionally render it > around the template. > > If I'm correct.. I feel like an unfortunate downside of this approach > is having to include that conditional layout code in every template.
That is not true. I always just call the one template with this logic i.e apptemplate.mak. You don't duplicate this code anywhere. This template takes care of rendering the layout and the layout renders the actual body content. If there is no layout (and this should only be for plain text stuff), then the content just gets rendered plain. > I > think we should be able to create layouts automatically like rails > does. Either we have an entire site layout or layouts by controllers. > Or, we should be able to create a routes like feature that > automatically decorates your template depending on the url.. > > Chad > > On Feb 21, 5:54 am, Contact 42 <[EMAIL PROTECTED]> wrote: > >> Chad wrote: >> >>> Just curious of how other pylons developers are doing site layout in >>> their apps? Are you guys mostly using the template and includes? >>> >>> I'm currently using genshi and xi:include. This method works.. but it >>> really seems like a lot of wasted code. In the past I've used several >>> methods for site layout. Once we wrote a "filter" that automatically >>> added a layout based on a url config file. We based this method off of >>> sitemesh (http://www.opensymphony.com/sitemesh/). Rails allows you to >>> automatically associate a layout with templates in a controller or all >>> templates. >>> >>> Just curious about what other people are doing and what you think of >>> rails/sitemesh.. >>> >> I think sitemesh is awesome. It keeps out of your way yet is so flexible. >> >> Don't know about genshi, but in mako I do the following: >> >> I render the following template for every request which contains the >> following code. It is passed two variables (the layout template, the >> actual page template). This allows me to change layouts on each request >> (if necessary just like sitemesh). >> >> == apptemplate.mak >> <% >> >> if c.layout_template: >> layout_template = self.get_namespace(c.layout_template) >> else: >> layout_template = None >> >> namespace = self.get_namespace(temp) >> body = capture(namespace.body) >> if hasattr(namespace, 'head'): >> head = capture(namespace.head) >> else: >> head = None >> %> >> >> %if layout_template: >> ${layout_template.layout(body, head=head)} >> %else: >> ${body} >> %endif >> > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
