Skip to content

Commit

Permalink
Merge pull request #332 from SteelyWing/patch-2
Browse files Browse the repository at this point in the history
Use abs path for cache key
  • Loading branch information
mitsuhiko committed Jun 6, 2014
2 parents 5f710a9 + 090680f commit 86b4b38
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions jinja2/environment.py
Expand Up @@ -757,14 +757,23 @@ def join_path(self, template, parent):
def _load_template(self, name, globals):
if self.loader is None:
raise TypeError('no loader for this environment specified')
try:
# use abs path for cache key
cache_key = self.loader.get_source(self, name)[1]
except RuntimeError:
# if loader does not implement get_source()
cache_key = None
# if template is not file, use name for cache key
if cache_key is None:
cache_key = name
if self.cache is not None:
template = self.cache.get(name)
template = self.cache.get(cache_key)
if template is not None and (not self.auto_reload or \
template.is_up_to_date):
return template
template = self.loader.load(self, name, globals)
if self.cache is not None:
self.cache[name] = template
self.cache[cache_key] = template
return template

@internalcode
Expand Down

0 comments on commit 86b4b38

Please sign in to comment.