|
|
Documentation - Tags
3.9.1. Core
The core tag library is aliased as "spy" by default.
This library contains various frequently-used tags: the parent tag, login tags,
and some tags for generating lists and tables from Python iterators.
Parent Tag
- <parent [src=url] [other parameters] />
Specifies a parent template to apply to the current page, which
is passed to the parent as child._body. Any extra parameters are also
passed in the child dictionary. If src is not given, 'parent.spi' used if it exists
in the current directory; otherwise, the default parent
is used as specified in the config module.
examples/hello-templated.spy
|
<spy:parent title="Hello, world!" />
[[-- Spyce can embed chunks of Python code, like this. --]]
[[\
import time
t = time.ctime()
]]
[[--
pull the count from the GET variable.
the int cast is necessary since request stores everything as a string
--]]
[[ for i in range(int(request.get1('count', 2))):{ ]]
<div>Hello, world!</div>
[[ } ]]
The time is now [[= t ]].
|
Run this code
|
Login Tags
Convenience Tags
These tags are shortcuts for creatings lists and tables. As with
the form tag library, any python
iterator may be given as the data parameter. Also as with the form tags,
any unrecognized parameters will be passed through to the generated HTML.
- <ul data=expr] />
Convenience tag for the common use of ul; equivalent to
<ul>
[[ for item in data:{ ]]
<li>[[= item ]]</li>
[[ } ]]
</ul>
- <ol data=expr] />
Like ul, but for ordered lists.
- <dl data=expr] />
Convenience tag for the common use of dl; equivalent to
<dl>
[[ for term, desc in data:{ ]]
<dt>[[= term ]]</dt>
<dd>[[= desc ]]</dd>
[[ } ]]
</dl>
- <table data=expr] />
Convenience tag for the common use of table; equivalent to
<table>
[[ for row in data:{ ]]
<tr>
[[ for cell in row:{ ]]
<td>[[= cell ]]</td>
[[ } ]]
</tr>
[[ } ]]
</table>
|