turbogears
embed multiple kid template files into a main one
In the main kid template file, I want it to have only div tags, each of which do only call a rendered kid file and paste content inside it. (like "include" function in php) but I don't know how to do this. Does someone have any ideas about it?
If you swap to genshi instead of the default kid you can do this with an include tag: <xi:include href="menu.html" /> Swapping to genshi is fairly easy, I think its a matter of confuration only. The templates tags works otherwise the same. You should rename the extensions from .kid to .html though.
You can first define a "base_layout.kid" template: <html xmlns:py="http://purl.org/kid/ns#"> <head> <title>App Name - ${page_title}</title> <link href="layout.css" type="text/css" rel="stylesheet" /> ${page_specific_css()} </head> <body> <h1>Now viewing: ${page_title} of App Name</h1> <content>Default content</content> <div class="footer">Page Footer Text</div> </body> </html> Then replace the "content" tag in "page.kid" with whatever data you want: <html py:layout="'base_layout.kid'" xmlns:py="http://purl.org/kid/ns#"> <link py:def="page_specific_css()" href="layout.css" type="text/css" rel="stylesheet" /> <div py:match="item.tag == 'content'"> <ul> <li>Content Item 1</li> <li>Content Item 2</li> <li>Content Item 3</li> </ul> </div> </html> You can check whether you get the correct html in python shell (after removing all the identifiers used): >>> import kid >>> t = kid.Template("page.kid") >>> print t.serialize()
Related Links
Turbogears 2.3.10 error kajiki template with pluggable application
Exposing an HTTP proxy through a Turbogears controller
Using kajiki in TG2.1
embed multiple kid template files into a main one