-
-
Notifications
You must be signed in to change notification settings - Fork 12
Templating Reference
For syntax, refer to Django's documentation.
Sets the autoescaping mode. mode may be one of 'off', 'html', 'js-string', 'csv', 'uri'/'url' or to restore the previous mode 'end'.
Outputs all variables accessible at this point in the template as a <dl> list. Intended for debugging purposes, not production.
Evaluates the contained template until {% each %}
to obtain a whitespace seperated list of HTTP or HTTPS URLs to download concurrently. Template rendering resumes after {% endfetch %}
once all URLs have been downloaded.
For each HTTP response obtained from fetch, each renders it's contained template until {% endfetch %}
with the parsed response stored in name.
The response is parsed as TSV or JSON (XML support is planned) according to the MIMEtype given by the server. If that MIMEtype is absent, it will be inferred.
Applies filters to the contained template until {% endfilter %}
. filters uses templating syntax, without the variable path or the preceding |
.
Evaluates the contained template until {% endfor %}
(or {% empty %}
) for each item contained in variable. Each time it assigns the item to value (which must be a global name), and the corrosponding key to key.
Evaluates the contained template until {% endfor %}
if there are no items in variable.
Evaluates the condition, and if truthy evaluates the contained template until {% endif %}
(or {% else %}
or {% elif %}
). The condition is a variable, or variables with infix operators (documented next) between them. Spaces are required between variables and operators.
In order of precedance (lowest binding to highest binding):
or
and
-
not
(prefix) -
<
,>
,<=
,>=
,==
,!=
Any operator may be prefixed with not to negate it.
If the expression evaluated to something falsy, evaluates the contained template until {% endif %}
.
If the expression evaluated to something falsy and the contained template until the next {% elif %}
or {% endif %}
.
Checks if any of the variables have changed since the last time this code was run. If so it runs the embedded template until {% endif %}
(or {% else %}
).
Evaluates if there are no changes.
Defines a new tag which takes [*key*=]*value*...
arguments and applies those variables to the {% macro %}
's contained template until {% endmacro %}
. The arguments to {% macro %}
are actually meaningless, but they can be used to document expected arguments for the newly defined tags.
Evaluates the SQL queries given by the contained template until {% each-row %}
, {% empty %}
, {% except %}
, or {% endquery %}
, and fetches limit rows of them combined. If limit is not specified, all rows will be fetched. Any embedded variable values will be passed to the query as strings and do not require quoting.
For performance and correctness, the valid tags within this subtemplate are a lot more limited. Specifically you can only use variables, {% trans %}
, {% with %}
, and anything defined via {% macro %}
.
SQL syntax errors are reported the same way as Prosody syntax errors, and any runtime errors renders as a red level-1 heading with an error icon.
Runs the contained template until {% empty %}
or {% endquery %}
for each fetched row, exposing all columns of that row as variables.
Evaluates the contained template until {% endquery %}
in the event that none of the queries yield any results.
Evaluates the SQL queries given by the contained template until {% each-row %}
, {% empty %}
, or {% endquery %}
for each row fetched by the outer {% query %}
. If any of these queries give no results, ignore that fetched row and do not count it.
The columns of the fetched row are exposed to the subtemplate as variables, and the same rules that apply to {% query %}
's subtemplate also applies here.
Parses all subtemplates seperated by {% alt %}
until {% endrandom %}
, and upon evaluation chooses a random one of those to render in it's place.
As per Django.
Translates the contained template until {% endtrans %}
(or {% plural %}
), possibly using the additional variables specified in the tag. It is courtious to avoid markup and templating where possible within the the body of a trans tag.
A preceding comment within this subtemplate may be split out specially by localization UIs.
Evaluates the contained template using the given additional variables.
Where not documented, these should be self-describing. If they're not, please document them here.
Assuming the value being filtered is a number that's kept as small as possible, maps it uniquely to another number evenly dispersed betwen 0 & range. Commonly used in combination with CSS hsl() colors.
mode is as-per {% autoescape mode %}.