title: SimpleTAL API: simpleTALUtils Module.
subject: Documentation on how to use the simpleTALUtils Module.

<h2>simpleTALUtils</h2>
This module holds optional classes and functions that might be of use while using SimpleTAL, but are not required by SimpleTAL directly.

<h3>def ExpandMacros (context, template, outputEncoding="utf-8")</h3>
This function can be used to expand a template which contains METAL macros, while leaving in place all the TAL and METAL commands.  Doing this makes editing a template which uses METAL macros easier, because the results of the macro can be seen immediately.

The macros referred to by the passed in template must be present in the context so that their contents can be referenced.  The outputEncoding determines the encoding of the returned string, which will contain the expanded macro.

<h3>TemplateCache</h3>
This class implements a cache for compiled templates which automatically invalidates entries when their template file changes.  The instance has one public method: getTemplate

<h4>getTemplate (name, inputEncoding="utf-8")</h4>

This method will return a compiled template from the file 'name'.  If the file ends in '.xml' it will be compiled using simpleTAL.compileXMLTemplate, otherwise it will be compiled as a HTML template.  If the method is called again it will check to see whether the file 'name' has changed since the last call, and if it has it will re-compile the template,otherwise it will return the cached version.

HTML Templates will be taken as being stored in the "inputEncoding", XML templates ignore this parameter.

<h4>getXMLTemplate (name)</h4>

This method will return a compiled XML template from the file 'name'.  This works identically to getTemplate as described above, except that it always treats the template as XML.

<a href="api.html">Back to SimpleTAL API</a>
