SimpleTAL API: simpleTALUtils Module.

Documentation on how to use the simpleTALUtils Module.

simpleTALUtils

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

def ExpandMacros (context, template, outputEncoding="utf-8")

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.

TemplateCache

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

getTemplate (name, inputEncoding="utf-8")

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.

getXMLTemplate (name)

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.

Back to SimpleTAL API

Last Modified: Sun, 01 Feb 2015 10:59:33 CET

Made with PubTal 3.5

Copyright 2021 Colin Stewart

Email: colin at owlfish.com