Permalink
Browse files

edit

  • Loading branch information...
fengbp authored and anandology committed Jul 2, 2010
1 parent d95836a commit e58ab3550353540bac38da8fbe8fcd1ff0019a93
Showing with 45 additions and 45 deletions.
  1. +45 −45 cookbook/template_cheetah.zh-cn.md
@@ -1,50 +1,50 @@
---
layout: default
-title: Use Cheetah template engine in webpy
+title: 在webpy中使用Cheetah模板引擎
---
-# Use Cheetah template engine in webpy
-
-### 问题:
-怎样在webpy中使用Cheetah模板引擎?
-
-### 解决:
-
-您需要先安装webpy(0.3)和Cheetah:[http://www.cheetahtemplate.org/](http://www.cheetahtemplate.org/). 然后尝试使用下面的代码段:
-
- # encoding: utf-8
- # File: code.py
-
- import web
- from web.contrib.template import render_cheetah
-
- render = render_cheetah('templates/')
-
- urls = (
- '/(first)', 'first',
- '/(second)', 'second'
- )
-
- app = web.application(urls, globals(), web.reloader)
-
- class first:
- def GET(self, name):
- # cheetah template takes only keyword arguments,
- # you should call it as:
- # return render.hello(name=name)
- # Below is incorrect:
- # return render.hello(name)
- return render.first(name=name)
-
- class second:
- def GET(self, name):
- return render.first(**locals())
-
- if __name__ == "__main__":
- app.run()
-
-模板文件
-
- ## File: templates/first.html
-
+# 在webpy中使用Cheetah模板引擎
+
+### 问题:
+怎样在webpy中使用Cheetah模板引擎?
+
+### 解决:
+
+您需要先安装webpy(0.3)和Cheetah:[http://www.cheetahtemplate.org/](http://www.cheetahtemplate.org/). 然后尝试使用下面的代码段:
+
+ # encoding: utf-8
+ # File: code.py
+
+ import web
+ from web.contrib.template import render_cheetah
+
+ render = render_cheetah('templates/')
+
+ urls = (
+ '/(first)', 'first',
+ '/(second)', 'second'
+ )
+
+ app = web.application(urls, globals(), web.reloader)
+
+ class first:
+ def GET(self, name):
+ # cheetah template takes only keyword arguments,
+ # you should call it as:
+ # return render.hello(name=name)
+ # Below is incorrect:
+ # return render.hello(name)
+ return render.first(name=name)
+
+ class second:
+ def GET(self, name):
+ return render.first(**locals())
+
+ if __name__ == "__main__":
+ app.run()
+
+模板文件
+
+ ## File: templates/first.html
+
hello, $name.

0 comments on commit e58ab35

Please sign in to comment.