4 messages in com.googlegroups.pylons-discussRe: template language requirements
FromSent OnAttachments
hagna17 Dec 2007 15:49 
Mike Orr17 Dec 2007 17:13 
hagna18 Dec 2007 08:42 
Mike Orr18 Dec 2007 11:57 
Subject:Re: template language requirements
From:Mike Orr (slug@public.gmane.org)
Date:12/18/2007 11:57:07 AM
List:com.googlegroups.pylons-discuss

On Dec 18, 2007 8:42 AM, hagna
<nate@public.gmane.org> wrote:

I want to make a templating language for internal use that has less features and different syntax.

I don't know what pylons expects of a templating language like genshi, kid, myghty or mako so it's hard to know if I have done everything.

I don't know what to expect in the arguments to render. Is that documented?

No, that's part of the problem. But the only ones that have been unambiguously defined are: format='html' fragment=True

In fact, those are the only options that *can* be passed if I'm reading the code right. The user-visible render() function is pylons.templating.render. It passes those two keyword args as separate arguments to pylons.templating.Buffet.render(), along with the three caching options. All other keyword args get passed as the 'namespace' dict; i.e., data values for the template.

'format' is for engines that can produce multiple output formats from the same template. Genshi/Kid use this to choose HTML 4, XHTML, XML, etc. Mako/Cheetah have only one output format, so they ignore this.

If 'fragment' is true, the plugin sound render just the named template, without any surrounding decorations from an inherited or site template. This is used in Ajax calls; e.g., to update a portion of a page. Kid supports fragments and I think Genshi and Myghty. Cheetah and Mako don't have the infrastructure to ignore inherited templates, because if the template author specified it, by golly it must be true. So they ignore this option. I submitted a patch to TurboCheetah that emulates fragments with a '#def' method, but the user has to write that method into the template.

'format' and 'fragment' show how Kid-centric Buffet is. Buffet was created so that people could use their existing Cheetah templates with TG, and because Kevin was tired of complaints that Kid was the only template engine available. But Kid needed 'format' and 'fragment', so by golly they were written into Buffet.