Loader¶
Load templates from files.
-
class
knights.loader.TemplateNotFound(Exception)¶ The exception class raised when a template can not be found.
-
class
knights.loader.TemplateLoader(paths)¶ Provides a way to load templates from a list of directories.
paths is a list of paths to search for template files. Relative paths will be resolved relative to CWD.
A TemplateLoader will also act as a cache if accessed as a dict.
>>> loader = TemplateLoader(['templates']) >>> tmpl = loader['index.html']
-
load(name, raw=False)¶ Find the template name in one of the paths and compile it.
If the raw flag is passed, the returned value will be the class, not an instance.
-