Latest release Supported Python versions https://travis-ci.org/zopefoundation/zope.tal.svg?branch=master https://coveralls.io/repos/github/zopefoundation/zope.tal/badge.svg?branch=master Documentation Status

The Zope3 Template Attribute Languate (TAL) specifies the custom namespace and attributes which are used by the Zope Page Templates renderer to inject dynamic markup into a page. It also includes the Macro Expansion for TAL (METAL) macro language used in page assembly.

The dynamic values themselves are specified using a companion language, TALES (see the zope.tales package for more).

The reference documentation for the TAL language is available at https://pagetemplates.readthedocs.io/en/latest/tal.html

Detailed documentation for this implementation and its API is available at https://zopetal.readthedocs.io/

Using zope.tal requires three steps: choosing an expression engine (usually zope.tales), creating a generator and parser, and then interpreting the compiled program:

from io import StringIO
from zope.tal.talgenerator import TALGenerator
from zope.tal.htmltalparser import HTMLTALParser
from zope.tal.talinterpreter import TALInterpreter

compiler = None # Will use a compiler for a dummy language
source_file = '<string>'
source_text = '<html><body><p>Hi</p></body></html>'
gen = TALGenerator(compiler, source_file=source_file)
parser = TALParser(gen)
program, macros = parser.getCode()

output = StringIO()
context = None # Usually will create a zope.tales context
interpreter = TALInterpreter(self.program, macros, context, stream=output)
result = output.getvalue()

These aspects are all brought together in zope.pagetemplate.

API Documentation:

Indices and tables