Login With Github

Language Reference: Syntax

The language reference is structured such that it can be read as a general introduction to the page templates language.

It's split into parts that correspond to each of the main language features.

You can safely skip this section if you're familiar with how template languages work or just want to learn by example.

An attribute language is a programming language designed to render documents written in XML or HTML markup. The input must be a well-formed document. The output from the template is usually XML-like but isn't required to be well-formed.

The statements of the language are document tags with special attributes, and look like this:

<p namespace-prefix:command="argument"> ... </p>

In the above example, the attribute namespace-prefix:command="argument" is the statement, and the entire paragraph tag is the statement's element. The statement's element is the portion of the document on which this statement operates.

The namespace prefixes are typically declared once, at the top of a template (note that prefix declarations for the template language namespaces are omitted from the template output):

<html xmlns="http://www.w3.org/1999/xhtml"

Thankfully, sane namespace prefix defaults are in place to let us skip most of the boilerplate:

<html xmlns="http://www.w3.org/1999/xhtml">
    <p tal:content="text"> ... </p>

Note how tal is used without an explicit namespace declaration. Chameleon sets up defaults for metal and i18n as well.

Note: Default prefixes are a special feature of Chameleon.

If the enable_data_attributes option is set then you can use data-prefix-command="argument" in addition to the namespace prefix attributes.

0 Comment