- METAL
The Macro Expansion Template Attribute Language complements TAL, providing macros which allow the reuse of code across template files. Both were created for
Zope but are used in other Python projects as well.Overview
METAL complements TAL with the ability to reuse code. It allows the developer to define and use macros, which in turn may have "slots"; when using a macro, variational content can be specified for a slot.
When Generating
XML documents, the XML namespace must be specified(
).xmlns:metal="http://xml.zope.org/namespaces/metal" Attributes
The following attributes are recognised, normally requiring a „
metal:
“ prefix:; define-macro: creates a macro; define-slot: creates a slot inside a macro; use-macro: uses a macro (normally given via a
TALES path expression); fill-slot: when using a macro, replaces the default content of the given slot; extend-macro: sinceZope v3: extends a macro, comparable to subclassing, by redefining of slotsNormally, just one of those is used at a time.
In cases when no tag is present which lends itself to take the attributes, and in special cases when more than one METAL attribute is needed, special METAL tags can be used, making the „metal:“ prefix optional. E. g. (sketched with Roundup in mind):
<html metal:define-macro="icing"> ... <metal:myslot define-slot="optional-form"/> ... </html> <html metal:use-macro="templates/page/macros/icing"> <form metal:fill-slot="optional-form" action="." tal:attributes="action context/designator"> ... </form>
</html>Usage
TAL/
TALES /METAL are used by the following projects:*
Zope (web-based application server)
*Roundup (issue tracker) External links
* [http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/AppendixC.stx#2-69 METAL Overview (Zope Book)]
Wikimedia Foundation. 2010.