Represent a collection of .Template
objects,
identifiable via URI.
A .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 .Template
object's .TemplateCollection
for resolution.
.TemplateCollection
is an abstract class,
with the usual default implementation being .TemplateLookup
.
Method | adjust_uri |
Adjust the given uri based on the calling filename. |
Method | filename_to_uri |
Convert the given filename to a URI relative to this .TemplateCollection . |
Method | get_template |
Return a .Template object corresponding to the given uri. |
Method | has_template |
Return True if this .TemplateLookup is capable of returning a .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
.TemplateCollection
subclass can place any string
identifier desired in the filename parameter of the
.Template
objects it constructs and have them come back
here.
mako.lookup.TemplateLookup
.TemplateCollection
.mako.lookup.TemplateLookup
Return a .Template
object corresponding to the given
uri.
The default implementation raises
.NotImplementedError
. Implementations should
raise .TemplateLookupException
if the given uri
cannot be resolved.
Parameters | |
uri | String URI of the template to be resolved. |
relativeto | if present, the given uri is assumed to be relative to this URI. |