|
 |
 |
 |
Examples
|
[[ Spyce ]]
Python Server Pages by Rimon Barr |
examples/template.spy
|
[[.import name=template]]
[[import sys]]
<html><body>
The template module interfaces with various templating
engines. <br>
It currently supports:
<a href="http://www.cheetahtemplate.org">Cheetah</a>
<hr>
[[
persona = 'world'
num = 10
]]
<b>Cheetah template:</b><br>
[[ try: { ]]
[[=template.cheetah('template.tmpl')]]
[[ } except ImportError: { ]]
Unable to import Cheetah.Compiler from path=[[=sys.path]]
<br><b>The Cheetah is likely not (properly) installed.</b>
[[ } ]]
<p>
</body></html>
|
Run this code.
(requires Spyce-enabled web server)
|
Supplemental files:
examples/template.tmpl
|
Hello $persona!
#for i in range($num)
$i #slurp
#end for
|
Back to List of Examples
|