|
|
Documentation - Language
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:
- <taglib:name attr1=val1 ...>
Active tags may include presentation and action code.
- [[-- Spyce comment --]]
Enclosed code is elided from the compiled Spyce class.
- [[\ Python chunk ]]
Embed python in your code.
- [[! Python class chunk ]]
Like chunks, but at the class level rather than the spyceProcess method.
- [[ Python statement(s) ]]
Like chunks, but may include braces to indicate that the block should continue after the ]].
- [[= Python expression ]]
Output the result of evaluating the given expression.
- [[. Spyce directive ]]
Pass options to the Spyce compiler.
- [[spy lambda ]]
Allows dynamic compilation of Spyce code to a python function.
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 within 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.
Sub-sections:
|