Wouter van Marle
wouter at squirrel-systems.com
Wed Jun 7 04:09:38 EDT 2006
This sounds very similar to my set-up. I have a base template.psp, containing the html header with css includes, and some divs, like: <html><head> header stuff </head><body> common banner <div id=navbar><%=navbar%></div> <div id=body><%=body%></div> common footer </body></html> Separately I have a python script, that parses the various parts. These body and navbar parts are often psp files with variables to be entered in their own right: I put them through the psp interpreter first, catch back the html as string (use _psp instead of psp which causes the page to be published), and put these strings in the variables as given above. Works like a charm! Templates are in: ./templates/template.psp (the main template) ./templates/en/body.psp (the English body and other templates) ./templates/cncn/body.psp (the Chinese simplified body and other templates) ./templates/cnhk/body.psp (the Chinese traditional body and other templates) Just keep a variable language set to the correct language, and with "os.path.join(TEMPLATEPATH, language, templatefilename)" I can very easily get the right template, add it in the main body, etc. Change the main body: changes are all over. Change the css files: layout changes all over. Hope it's useful for you. Wouter. On Wed, 2006-06-07 at 09:21 +0200, Julien Cigar wrote: > Jim's right, my idea was to do a kind of "main" template container, > something like : > > <html> > <head>...</head> > <body> > <div id="container"> > <div id="header"> ... </div> > <div id="menu"> ... </div> > <div id="anothercommonpart"> ... </div> > > <div id="main"> > <!-- MAIN STUFF GOES HERE --> > <%@ include file = "..." %> > </div> > > <div id="footer">...</div> > </div> > > in my example "body_template = psp.PSP(req, filename="list.psp")" whould > be the included file and the "mytemplate.run({'body' : body_template})" > would be the "main" template. > Both are psp.PSP() instances. I thought I could to something like : > > body_template = psp.PSP(file="foobar.psp") > main = psp.PSP(file="main_template.psp") > main.run(dict(body=body_template)) > > and later in the "main" template and <%@ include file="<%= body %>" %>, > but as Jim said this doesn't work ... > > Julien > > Jim Gallacher wrote: > > David Bear wrote: > >> On Tue, Jun 06, 2006 at 12:03:37PM -0400, Jim Gallacher wrote: > >>> As an alternative you could do: > >>> > >>> body_template = psp.PSP(req, filename="list.psp") > >>> mytemplate.run({'body' : body_template}) > >> > >> this syntax baffles me. where is 'mytemplate' defined? and what kind > >> of an object is it? > > > > It's a reference to snippet of code in Julien's message. Since the > > thread was discussing psp templates, one can assume his reference to > > mytemplate.run() refers to a PSP instance created elsewhere in his > > code which was not in the message but can be inferred. > > > > Jim > > > > _______________________________________________ > > Mod_python mailing list > > Mod_python at modpython.org > > http://mailman.modpython.org/mailman/listinfo/mod_python > > > >
|