API Reference for Enthought Tool Suite 3.2.0
This is a simple template engine. It supports a limited number of control structures, as well as simple python expressions referencing variables in the template context.
Usage:
>>> t = Template(template_code)
>>> context = { 'spam' : 1, 'eggs' : 2 }
>>> text = t.render(context)
Template tags:
{{ EXPR }}
Evaluate EXPR against the template context and insert the result in the output.
{% assign VAR=EXPR %}
Assign the name VAR in the current context to the value of EXPR.
{% block NAME %}{% endblock %}
Everything enclosed in a block may be overridden by an extending template.
{% extends "base_template" %}
Render "base_template", but replace all blocks that are overridden in this template
{% for VAR1[,VAR2[,VAR3]] in LIST_EXPR %}{% endfor %}
A for loop, just as in Python.
{% if TEST %} [{% else %}] {% endif %}
Evaluate test and execute the appropriate block.
{% include TEMPLATE [PARAM1=EXPR1 [PARAM2=EXPR2]] %}
Evaluate the specified template against the current context (with specified additional parameters), and insert the resulting text in the output.
NODE_ASSIGN = 9
NODE_BLOCK = 6
NODE_EXTENDS = 7
NODE_FOR = 3
NODE_GENID = 11
NODE_IF = 4
NODE_INCLUDE = 8
NODE_LIT = 2
NODE_SEQ = 1
NODE_SUPER = 10
NODE_VARIABLE = 5
TOK_CONTROL = 2
TOK_LITERAL = 0
TOK_VARIABLE = 1
TOKEN_CONTROL_TAG = re.compile('\\{%([^%\\}]|%[^\\}])*%\\}')
TOKEN_VARIABLE_TAG = re.compile('\\{\\{([^\\}]|\\}[^\\}])*\\}\\}')
| Local name | Refers to |
|---|---|
| format_exception | traceback.format_exception |
| format_stack | traceback.format_stack |
| re | re |
| sys | sys |
© Copyright 2002-2009 Enthought, Inc.