atom feed4 messages in com.googlegroups.mako-discuss[Mako] Re: conditional inheritance
FromSent OnAttachments
AnilOct 15, 2007 12:01 pm 
Michael BayerOct 15, 2007 12:51 pm 
Div ShekharOct 15, 2007 10:04 pm 
Michael BayerOct 15, 2007 10:30 pm 
Subject:[Mako] Re: conditional inheritance
From:Michael Bayer (mike@zzzcomputing.com)
Date:Oct 15, 2007 12:51:19 pm
List:com.googlegroups.mako-discuss

inherit is interpreted before the template is, so youd have to make a global-level function like:

<%!

def inherit(context): if context.get('foo') == 'bar': return '/base.html' else: return None %> <%inherit file="${inherit(context)}"/>

On Oct 15, 2007, at 3:01 PM, Anil wrote:

% if c.no_template: <%inherit file="/base.html"/> % endif

Should doing something like work?

I have a controller that render's a form.html. In that form I have _remote tag (AJAX call), that calls this same template. If I don't have that if condition, the whole inherited template is displayed in this AJAX tag rather than just the template.

form.html: <%inherit file="/base.html"> ${ h.form_remote_tag(url=h.url(controller="/host", action="compare"), update="reportBox") } <div id="reportBox"></div> ...

def compare(self): ... render ('form.html')