MCPcopy Create free account
hub / github.com/pyload/pyload / get_source

Method get_source

module/lib/jinja2/loaders.py:72–93  ·  view source on GitHub ↗

Get the template source, filename and reload helper for a template. It's passed the environment and template name and has to return a tuple in the form ``(source, filename, uptodate)`` or raise a `TemplateNotFound` error if it can't locate the template. The source pa

(self, environment, template)

Source from the content-addressed store, hash-verified

70 has_source_access = True
71
72 def get_source(self, environment, template):
73 """Get the template source, filename and reload helper for a template.
74 It's passed the environment and template name and has to return a
75 tuple in the form ``(source, filename, uptodate)`` or raise a
76 `TemplateNotFound` error if it can't locate the template.
77
78 The source part of the returned tuple must be the source of the
79 template as unicode string or a ASCII bytestring. The filename should
80 be the name of the file on the filesystem if it was loaded from there,
81 otherwise `None`. The filename is used by python for the tracebacks
82 if no loader extension is used.
83
84 The last item in the tuple is the `uptodate` function. If auto
85 reloading is enabled it's always called to check if the template
86 changed. No arguments are passed so the function must store the
87 old state somewhere (for example in a closure). If it returns `False`
88 the template will be reloaded.
89 """
90 if not self.has_source_access:
91 raise RuntimeError('%s cannot provide access to the source' %
92 self.__class__.__name__)
93 raise TemplateNotFound(template)
94
95 def list_templates(self):
96 """Iterates over all templates. If the loader does not support that

Callers 4

loadMethod · 0.95
get_sourceMethod · 0.45
get_sourceMethod · 0.45
compile_templatesMethod · 0.45

Calls 1

TemplateNotFoundClass · 0.90

Tested by

no test coverage detected