Lines Matching +full:environment +full:- +full:file
1 # -*- coding: utf-8 -*-
39 implement a custom loading mechanism. The environment provides a
43 A very basic example for a loader that looks up templates on the file
54 def get_source(self, environment, template):
59 with file(path) as f:
60 source = f.read().decode('utf-8')
70 def get_source(self, environment, template): argument
72 It's passed the environment and template name and has to return a
78 be the name of the file on the filesystem if it was loaded from there,
100 def load(self, environment, name, globals=None): argument
113 source, filename, uptodate = self.get_source(environment, name)
117 bcc = environment.bytecode_cache
119 bucket = bcc.get_bucket(environment, name, filename, source)
125 code = environment.compile(source, name, filename)
134 return environment.template_class.from_code(environment, code,
139 """Loads templates from the file system. This loader can find templates
140 in folders on the file system and is the preferred way to load them.
149 Per default the template encoding is ``'utf-8'`` which can be changed
160 def __init__(self, searchpath, encoding='utf-8', followlinks=False):
167 def get_source(self, environment, template): argument
214 Per default the template encoding is ``'utf-8'`` which can be changed
217 from the file system and not a zip file.
221 encoding='utf-8'):
231 def get_source(self, environment, template): argument
282 def get_source(self, environment, template): argument
313 def get_source(self, environment, template): argument
333 By loading ``'app1/index.html'`` the file from the app1 package is loaded,
334 by loading ``'app2/index.html'`` the file from the second.
349 def get_source(self, environment, template): argument
352 return loader.get_source(environment, name)
354 # re-raise the exception with the correct filename here.
359 def load(self, environment, name, globals=None): argument
362 return loader.load(environment, local_name, globals)
364 # re-raise the exception with the correct filename here.
393 def get_source(self, environment, template): argument
396 return loader.get_source(environment, template)
402 def load(self, environment, name, globals=None): argument
405 return loader.load(environment, name, globals)
431 Templates can be precompiled with :meth:`Environment.compile_templates`.
459 return 'tmpl_' + sha1(name.encode('utf-8')).hexdigest()
466 def load(self, environment, name, globals=None): argument
480 return environment.template_class.from_module_dict(
481 environment, mod.__dict__, globals)