A macro library is a collection of macros which can be used by templates.
A macro library can be defined as in the example below:
- All libraries have the extension
.tml(template macro library), therefore the file above is called
- Access to the data and the module controller is not allowed as the
moduleCtrlobject are not put in the Library's scope. The only way in which a Library can access this and other data supplied by the template is by taking them as macro parameters.
- Libraries cannot use CSS templates. The option to do so will be offered in a future release.
A macro library can be declared in the
macrolibs section of the Template statement. The declaration includes a configuration, which is a number of
handles and a
classpaths. The handles can then be used throughout the template to access the library's macros as shown in the example below.
- Can include several handle-classpath couples in the argument.
- Can also be used in Libraries exactly like it's used in Templates, making it possible to arbitrarily organize library inclusion hierarchies.
- Cannot be used in CSS templates.
Libraries can use scripts just like templates by providing them in the Library declaration. From a design standpoint, access to the script functions should be restricted to libraries, even though script methods are still accessible as properties of the handle in the template. An example of this is shown below.
- Simple macro definition inside a library
- Simple macro definition inside a library with an associated script