|
|
/ Hathaway Weblog / Zope 3 a la carte: page templates |
Shane
:: Zope
:: October 05, 2004
#
Zope 3 a la carte: page templates
My first experiment in using Zope 3 as a library went very well. I wanted to use the Zope Page Templates (ZPT) implementation in Zope 3 outside the Zope 3 framework. No problem!
from zope.pagetemplate import pagetemplate
text = '''\
<html>
<head>
<title tal:content="options/title">Title goes here</title>
</head>
<body>
<h1 tal:content="options/title">Title goes here</h1>
<ul>
<li tal:repeat="bullet options/bullets" tal:content="bullet">item</li>
</ul>
</body>
</html>
'''
def main():
pt = pagetemplate.PageTemplate()
pt.pt_edit(text, 'text/html')
print pt(title='Success!', bullets=[1,2,3])
if __name__ == '__main__':
main()
text = '''\
<html>
<head>
<title tal:content="options/title">Title goes here</title>
</head>
<body>
<h1 tal:content="options/title">Title goes here</h1>
<ul>
<li tal:repeat="bullet options/bullets" tal:content="bullet">item</li>
</ul>
</body>
</html>
'''
def main():
pt = pagetemplate.PageTemplate()
pt.pt_edit(text, 'text/html')
print pt(title='Success!', bullets=[1,2,3])
if __name__ == '__main__':
main()
Comments
(2)
Comments
Ivo van der Wijk
(December 04, 2004 05:21)
As far as I know, Five (Zope3 for Zope2) uses Zope3 as a library as well. Nifty :)
Chris
(September 16, 2005 12:43)
While your are talking about Zope 3, I thought I would mention that I am aware of this "TAL outside of Zope" project from the people at tummy.com:
JotWEB: http://jotweb.tummy.com/
