Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reverted to previous change, I think
- Loading branch information
1 parent
4b17be4
commit d4bc2bc
Showing
1 changed file
with
52 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,54 @@ | ||
# Templating with Genshi | ||
|
||
code.py | ||
------- | ||
|
||
Put your "code.py" in root directory. | ||
|
||
# -*- coding: utf-8 -*- | ||
|
||
import web | ||
from web.contrib import template | ||
|
||
render = template.render_genshi(['./templates/']) | ||
|
||
urls = ( | ||
'/', 'index' | ||
) | ||
|
||
class index: | ||
def GET(self): | ||
name = 'John Doe' | ||
return render.index(name=name) | ||
|
||
app = web.application(urls, globals()) | ||
if __name__ == "__main__": | ||
app.run() | ||
|
||
index.html | ||
---------- | ||
|
||
Put your "index.html" in "template" directory. | ||
|
||
<?xml version="1.0" encoding="utf-8"?> | ||
<html xmlns:py="http://genshi.edgewall.org/"> | ||
<body> | ||
<p>Hello, $name.</p> | ||
</body> | ||
</html> | ||
|
||
refer | ||
----- | ||
|
||
* [genshi on gae 2010 - Genshi | Google Groups](http://groups.google.com/group/genshi/t/4f3fa1beddbd4ffc) | ||
* [/trunk/examples/webpy – Genshi](http://genshi.edgewall.org/browser/trunk/examples/webpy?rev=332) | ||
* [api docs (web.py)](http://webpy.org/docs/0.3/api) | ||
<p> | ||
|
||
<h2>code.py</h2> | ||
<p>Put your "code.py" in root directory. | ||
</p> | ||
<pre><code># -*- coding: utf-8 -*- | ||
|
||
import web | ||
from web.contrib import template | ||
|
||
render = template.render_genshi(['./templates/']) | ||
|
||
urls = ( | ||
'/', 'index' | ||
) | ||
|
||
class index: | ||
def GET(self): | ||
name = 'John Doe' | ||
return render.index(name=name) | ||
|
||
app = web.application(urls, globals()) | ||
if __name__ == "__main__": | ||
app.run() | ||
</code></pre> | ||
<h2>index.html</h2> | ||
<p>Put your "index.html" in "template" directory. | ||
</p> | ||
<pre><code><?xml version="1.0" encoding="utf-8"?> | ||
<html xmlns:py="http://genshi.edgewall.org/"> | ||
<body> | ||
<p>Hello, $name.</p> | ||
</body> | ||
</html> | ||
</code></pre> | ||
<h2>refer</h2> | ||
<ul> | ||
<li> | ||
<a href="http://groups.google.com/group/genshi/t/4f3fa1beddbd4ffc">genshi on gae 2010 - Genshi | Google Groups</a> | ||
</li> | ||
|
||
<li> | ||
<a href="http://genshi.edgewall.org/browser/trunk/examples/webpy?rev=332">/trunk/examples/webpy – Genshi</a> | ||
</li> | ||
|
||
<li> | ||
<a href="http://webpy.org/docs/0.3/api">api docs (web.py)</a> | ||
</li> | ||
</ul> | ||
|
||
|
||
</p> |