4 <:spool:>

<:spool name:><:/spool:>

Takes the content generated between the open and close <:spool:> tags and assigns it to the local variable named name. The name argument cannot be a Python expression, only a string with the variable name.

This tag is deceptively powerful: you can execute any STML you wish, collect all the HTML output into a single string, and do anything to that string after ending the <:spool:>. In this example, the variable spoolVar would end up containing the string :

<:set myUrl "index.html":>
<:spool spoolVar:>
<:url path=`myUrl` text="Click here":>
<:/spool:>

Spooling is equivalent to the following Python code in a Python component:

import sys, cStringIO
tempname = sys.stdout
sys.stdout = cStringIO.StringIO()
# stuff between <:spool:> tags 
name = sys.stdout.getvalue()
sys.stdout = tempname