Unfortunately, my company uses Genshi so I'm out of luck :( Maybe I'll build a sitemesh into pylons so that it works with all templates...
On Feb 21, 2:04 pm, Contact 42 <[EMAIL PROTECTED]> wrote: > The other good thing about this approach is that you can get all the > goodness of sitemesh with just a bit more code. > eg. > > 1. setup a config or just a dict to map pages (using regexp) to layouts, > just like sitemesh does with decorator.xml. > 2. Change the default mapping using more parameters in (c) > > huy > > > 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. 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 -~----------~----~----~----~------~----~------~--~---
