欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2, C++/F#/Lisp
CheetahTemplate
来自开放百科 - 灰狐
(版本间的差异)
第3行: | 第3行: | ||
http://www.cheetahtemplate.org | http://www.cheetahtemplate.org | ||
− | == | + | ==Quickstart== |
+ | 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 | ||
+ | ==Cases== | ||
*http://reddit.com | *http://reddit.com |
2007年2月6日 (二) 17:24的版本
Cheetah - The Python-Powered Template Engine
http://www.cheetahtemplate.org
Quickstart
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
Cases
分享您的观点