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

transparent transparent transparent
Documentation - Language
[[ Spyce ]]
Python Server Pages
by Rimon Barr

Prev: 1.3 - Getting Started Up: Table of Contents Next: 2.1 - Plain HTML and Active Tags

2. LANGUAGE

The basic structure of a Spyce script is an HTML file with embeddings. There are six types of possible embeddings among the plain HTML text:

The majority of HTML strings are written out to the browser, verbatim. However, the Spyce language also supports "active" HTML tags via tag libraries, in the sense that they can execute custom code. Spyce comments are elided. The Spyce directives affect the interpreter behaviour. Python statements and chunks are executed. Finally, Python expressions are evaluated and the result is emitted to the browser. Each Spyce tag type has a unique beginning delimeter, namely [[, [[\, [[=, [[. or [[--. All tags end with ]], except comment tags, which end with --]].

Since [[ and ]] are special Spyce delimeters, one would escape them as \[[ and \]] for use in HTML text. They can not be escaped in Python code, but the string expressions ("["*2) and ("]"*2), or equivalent expressions, can be used instead, or the brackets can be conveniently separated with a space in the case of list or slicing expressions.

In addition, Spyce scripts are first-class members of the Spyce language: you can create a Spyce lambda out of a Spyce string using the syntax below, in any of the Spyce Python elements (statements, chunks and expressions). A Spyce lambda can be invoked like a regular Python function, and its execution context (i.e. modules) is that of its calling point. Spyce lambdas do not currently support nested variable scoping, nor default parameters.

Note that braces in "[parameters]" above means that a Spyce lambda may have zero parameters. Consider the parameter list of a Spyce lambda to be the same as the parameter list of a Python lambda definition.


Prev: 1.3 - Getting Started Up: Table of Contents Next: 2.1 - Plain HTML and Active Tags

Sub-sections:


© 2002 Rimon Barr
email: rimon AT acm DOT org
Spyce Powered SourceForge Logo [[ Spyce ]]
Python Server Pages
version 1.3.10