{{{ #!rst ============================ Markup XML Template Language ============================ Markup provides a simple XML-based template language that is heavily inspired by Kid_, which in turn was inspired by a number of existing template languages, namely XSLT_, TAL_, and PHP_. .. _kid: http://kid-templating.org/ .. _python: http://www.python.org/ .. _xslt: http://www.w3.org/TR/xslt .. _tal: http://www.zope.org/Wikis/DevSite/Projects/ZPT/TAL .. _php: http://www.php.net/ This document describes the template language and will be most useful as reference to those developing Markup templates. Templates are XML files of some kind (such as XHTML) that include processing directives_ (elements or attributes identified by a separate namespace) that affect how the template is rendered, and template expressions_ that are dynamically substituted by variable data. .. contents:: Contents :depth: 3 .. sectnum:: ---------- Python API ---------- The Python code required for templating with Markup is generally based on the following pattern: * Attain a ``Template`` object from a string or file object containing the template XML source. This can either be done directly, or through a ``TemplateLoader`` instance. * Call the ``generate()`` method of the template, passing any data that should be made available to the template as keyword arguments. * Serialize the resulting stream using its ``render()`` method. For example:: from markup.template import Template tmpl = Template('
Bar
Bar
Hello, ${name}!
${greeting('world')} ${greeting('everyone else')}Hello, world!
Hello, everyone else!
Hello, world!
${greeting}Hello, world!
Hello, ${name}!