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/tag.spy
[[.taglib name=core as=spy]]
[[.taglib name=myTaglib as=me]]
<html><body>
<spy:for var=x items="=range(2,6)">
  <me:foo val="=x">size <spy:print val="=x" /></me:foo>
</spy:for>
</body></html>
Run this code.
(requires Spyce-enabled web server)

Supplemental files:

examples/myTaglib.py
from spyceTag import spyceTagLibrary, spyceTagPlus

class tag_foo(spyceTagPlus):
  name = 'foo'
  mustend = 1
  def syntax(self):
    self.syntaxPairOnly()
    self.syntaxExist('val')
    self.syntaxNonEmpty('val')
  def begin(self, val):
    val = self.contextEval(val)
    self.getOut().write('<font size="%s"><b>' % str(val))
  def end(self):
    self.getOut().write('</b></font><br>')

class myTaglib(spyceTagLibrary):
  tags = [
    tag_foo, 
  ]

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