CheetahTemplate

来自开放百科 - 灰狐
(版本间的差异)
跳转到: 导航, 搜索
第39行: 第39行:
 
*[[PyBlosxom]]
 
*[[PyBlosxom]]
 
*http://linuxgazette.net/
 
*http://linuxgazette.net/
 +
 +
[[Category:Template]]
 +
[[Category:Python]]

2010年8月16日 (一) 13:28的版本

Cheetah - The Python-Powered Template Engine

http://www.cheetahtemplate.org

Quickstart

Debian用户

apt-get install python2.3-cheetah
apt-get install python2.4-cheetah
Cheetah 被安装到 /usr/lib/python2.4/site-packages/Cheetah 

其他用户

python setup.py install 
/usr/local/Python2.5/lib/site-packages/Cheetah
or 
C:\Python25\Lib\site-packages\Cheetah
>>> from Cheetah.Template import Template
>>> templateDef = """
... <HTML>
... <HEAD><TITLE>$title</TITLE></HEAD>
... <BODY>
... $contents
... ## this is a single-line Cheetah comment and won't appear in the output
... #* This is a multi-line comment and won't appear in the output
...    blah, blah, blah 
... *#
... </BODY>
... </HTML>"""
>>> nameSpace = {'title': 'Hello World Example', 'contents': 'Hello World!'}
>>> t = Template(templateDef, searchList=[nameSpace])
>>> print t
>>> nameSpace['title'] = 'Huihoo'
>>> print t

User

分享您的观点
个人工具
名字空间

变换
操作
导航
工具箱