[Twisted-web] Nested Nevow templates

Erik Swan erik at splunktechnology.com
Thu Nov 4 14:33:10 MST 2004


I'm somewhat new to Nevow and have a simple question - btw, it maybe 
already possible and i missed the man page...

We mostly use HTML based templates to drive our presentations as we have 
an html designer that can design and maintain a large majority of the UI 
without knowledge of any coding.  The designer delivers html that can be 
rendered on its own for review but also adds in directives, patterns and 
slots to make the programmers life easier.

My question centers around the best way to have nested templates - that 
is i'd like a directive that would function as an include and all the 
appropriate Nevow render code get executed automatically. That way our 
designer can build a header, footer, sidebars, and other html components 
as separate files and the main template just "includes" as appropriate.  
Something like
  <nevow:include name="blah.html">

Additionally, and here is my Nevow ignorance, there must be a simple few 
lines of code that does the equivalent in code for example if i had:
  <nevow:render name = templateName>

then in...
  def render_templateName(self, context, data):
      #load and render file templateName as include and return result

Lastly, if the above method works OK then I'd rather have
  <nevow:render name=include nevow:arg=templateName>
where i can have a generic include render method and take an argument 
from the html tag.

So, like i said, being new this maybe all be easy/possible and i just 
missed it. Also, i've felt the wrath of mvc and proper separation of 
code from html for almost 10 years now and i understand how the above is 
in violation ;-)

Thanks in advance for any help.

More information about the Twisted-web mailing list