Mako is a free template library written in Python that will provide a familiar, non-XML syntax which compiles into Python modules for maximum performance.
Mako's syntax and API borrows from the best ideas of many others, including Django templates, Cheetah, Myghty, and Genshi.
Conceptually, Mako is an embedded Python (i.e. Python Server Page) language, which refines the familiar ideas of componentized layout and inheritance to produce one of the most straightforward and flexible models available, while also maintaining close ties to Python calling and scoping semantics.
Here are some key features of "Mako":
· Super-simple API. For basic usage, just one class, Template is needed.
· Insanely Fast.
Standard template features:
· control structures constructed from real Python code (i.e. loops, conditionals)
· straight Python blocks, inline or at the module-level
· plain old includes
Callable blocks:
· can access variables from their enclosing scope as well as the template's request context
· can be nested arbitrarily
· can specify regular Python argument signatures
· outer-level callable blocks can be called by other templates or controller code (i.e. "method call")
· Calls to functions can define any number of sub-blocks of content which are accessible to the called function (i.e. "component-call-with-content"). This is the basis for nestable custom tags.
Inheritance:
· supports "multi-zoned" inheritance - define any number of areas in the base template to be overridden.
· supports "chaining" style inheritance - call next.body() to call the "inner" content.
· the full inheritance hierarchy is navigable in both directions (i.e. parent and child) from anywhere in the chain.
· inheritance is dynamic ! Specify a function instead of a filename to calculate inheritance on the fly for every request.
What's New in This Release: [ read full changelog ]
· The tag allows expressions for the `file` argument, i.e. with ${}. The `context` variable, if needed, must be referenced explicitly. [ticket:141]
· ${} expressions embedded in tags, such as , now allow multiline Python expressions. - Fixed previously non-covered regular expression, such that using a ${} expression inside of a tag element that doesn't allow them raises a CompileException instead of silently failing.
· Added a try/except around "import markupsafe". This to support GAE which can't run markupsafe. [ticket:151] No idea whatsoever if the install_requires in setup.py also breaks GAE, couldn't get an answer on this.