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

Categories

HOME
maven
xamarin
yii2
hook
cookies
reflection
single-sign-on
android-4.4-kitkat
filtering
tizen-web-app
fingerprint
pivotal-cloud-foundry
indesign
portia
google-cloud-spanner
windows-azure-storage
messages
facebook-page
google-static-maps
introduction
arabic
web-sql
devops
trading
javacv
neo4j-spatial
vision
bluestacks
react-chartjs
preg-match-all
overriding
android-ble
ansible-playbook
angularjs-factory
opshub
dism
particles.js
eclipse-scout
gulp-sourcemaps
isbn
estimote
eclipse-gef
websphere-mq-fte
qwt
sage-one
hls.js
elgg
setter
flow-control
nbconvert
topbeat
fody
websitepanel
lttng
make-install
ipconfig
unity-networking
lib.web.mvc
qdialog
pundit
apache-commons-fileupload
facebook-graph-api-v2.4
knuth
android-nested-fragment
qcodo
asp.net-web-api-odata
contenttype
jboss-weld
ccss
back-stack
django-nonrel
pushbackinputstream
jquery-mobile-dialog
anonymous-methods
mt
eclipse-templates
netbeans-7.1
lpeg
sortable-tables
sproutcore-2
mozilla-prism
dbal
multi-tier
zend-tool
thread-local-storage
signal-handling

Resources

Encrypt Message