Lines Matching defs:the
26 '..' in the path it will raise a `TemplateNotFound` error.
44 `get_template` method that calls the loader's `load` method to get the
47 A very basic example for a loader that looks up templates on the file
68 #: if set to `False` it indicates that the loader cannot provide access
69 #: to the source of templates.
77 """Get the template source, filename and reload helper for a template.
78 It's passed the environment and template name and has to return a
79 tuple in the form ``(source, filename, uptodate)`` or raise a
80 `TemplateNotFound` error if it can't locate the template.
82 The source part of the returned tuple must be the source of the
83 template as a string. The filename should be the name of the
84 file on the filesystem if it was loaded from there, otherwise
85 ``None``. The filename is used by Python for the tracebacks
88 The last item in the tuple is the `uptodate` function. If auto
89 reloading is enabled it's always called to check if the template
90 changed. No arguments are passed so the function must store the
92 the template will be reloaded.
96 f"{type(self).__name__} cannot provide access to the source"
101 """Iterates over all templates. If the loader does not support that
102 it should raise a :exc:`TypeError` which is the default behavior.
113 """Loads a template. This method looks up the template in the cache
123 # first we try to get the source for this template together
124 # with the filename and the uptodate function.
127 # try to load the code from the bytecode cache if there is a
135 # date) etc. we compile the template
139 # if the bytecode cache is available and the bucket doesn't
140 # have a code so far, we give the bucket the new code and put
141 # it back to the bytecode cache.
152 """Load templates from a directory in the file system.
155 the current working directory.
162 order, stopping at the first matching template.
168 :param searchpath: A path, or list of paths, to the directory that
169 contains the templates.
170 :param encoding: Use this encoding to read the text from template
172 :param followlinks: Follow symbolic links in the path.
175 Added the ``followlinks`` parameter.
198 # segments breaking out of the search directory.
241 :param package_name: Import name of the package that contains the
243 :param package_path: Directory within the imported package that
244 contains the templates.
247 The following example looks up templates in the ``pages`` directory
248 within the ``project.ui`` package.
257 installation methods the way this loader requires.
289 # Make sure the package exists. This also makes namespace
293 assert spec is not None, "An import spec was not found for the package."
295 assert loader is not None, "A loader was not found for the package."
311 # A single module file, use the parent directory instead.
334 # segments breaking out of the search directory. Use normpath to
361 # Could use the zip's mtime for all template mtimes, but
362 # would need to safely reload the module if it's out of
384 "This zip import does not have the required"
396 # Find names under the templates directory that aren't directories.
429 """A loader that is passed a function which does the loading. The
430 function receives the name of the template and has to return either
431 a string with the template source, a tuple in the form ``(source,
432 filename, uptodatefunc)`` or `None` if the template does not exist.
441 and has to return `True` if the template is still up to date. For more
442 details have a look at :meth:`BaseLoader.get_source` which has the same
475 to a prefix. The prefix is delimited from the template by a slash per
476 default, which can be changed by setting the `delimiter` argument to
484 By loading ``'app1/index.html'`` the file from the app1 package is loaded,
485 by loading ``'app2/index.html'`` the file from the second.
509 # re-raise the exception with the correct filename here.
510 # (the one that includes the prefix)
524 # re-raise the exception with the correct filename here.
525 # (the one that includes the prefix)
537 """This loader works like the `PrefixLoader` just that no prefix is
538 specified. If a template could not be found by one loader the next one
608 # create a fake module that looks for the templates in the
621 # the only strong reference, the sys.modules entry is weak
622 # so that the garbage collector can remove it once the
652 # remove the entry from sys.modules, we only want the attribute
653 # on the module object we have stored on the loader.