Represent a collection of :class:`.Template` objects, identifiable via URI. A :class:`.TemplateCollection` is linked to the usage of all template tags that address other templates, such as ``<%include>``, ``<%namespace>``, and ``<%inherit>``. The ``file`` attribute of each of those tags refers to a string URI that is passed to that :class:`.Template` object's :class:`.TemplateCollection` for resolution. :class:`.TemplateCollection` is an abstract class, with the usual default implementation being :class:`.TemplateLookup`.
Method | adjust |
Adjust the given ``uri`` based on the calling ``filename``. |
Method | filename |
Convert the given ``filename`` to a URI relative to this :class:`.TemplateCollection`. |
Method | get |
Return a :class:`.Template` object corresponding to the given ``uri``. |
Method | has |
Return ``True`` if this :class:`.TemplateLookup` is capable of returning a :class:`.Template` object for the given ``uri``. |
mako.lookup.TemplateLookup
Adjust the given ``uri`` based on the calling ``filename``. When this method is called from the runtime, the ``filename`` parameter is taken directly to the ``filename`` attribute of the calling template. Therefore a custom :class:`.TemplateCollection` subclass can place any string identifier desired in the ``filename`` parameter of the :class:`.Template` objects it constructs and have them come back here.
mako.lookup.TemplateLookup
Convert the given ``filename`` to a URI relative to this :class:`.TemplateCollection`.
mako.lookup.TemplateLookup
Return a :class:`.Template` object corresponding to the given ``uri``. The default implementation raises :class:`.NotImplementedError`. Implementations should raise :class:`.TemplateLookupException` if the given ``uri`` cannot be resolved. :param uri: String URI of the template to be resolved. :param relativeto: if present, the given ``uri`` is assumed to be relative to this URI.