spyce
home
license
community
download
examples
resources
wishlist
contrib (@sf)
documentation
intro
lang
runtime
modules
tags
install
exits
sourceforge
statistics
freshmeat

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


© 2002-05 Rimon Barr
email: rimon@acm.org
Spyce Powered SourceForge Logo [[ Spyce ]]
Python Server Pages
version 1.3.13