Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix DictLoader uptodate callback #162

Merged
merged 1 commit into from May 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion jinja2/loaders.py
Expand Up @@ -274,7 +274,7 @@ def __init__(self, mapping):
def get_source(self, environment, template):
if template in self.mapping:
source = self.mapping[template]
return source, None, lambda: source != self.mapping.get(template)
return source, None, lambda: source == self.mapping.get(template)
raise TemplateNotFound(template)

def list_templates(self):
Expand Down
7 changes: 7 additions & 0 deletions jinja2/testsuite/loader.py
Expand Up @@ -93,6 +93,13 @@ def get_source(self, environment, template):
assert 'two' not in env.cache
assert 'three' in env.cache

def test_dict_loader_cache_invalidates(self):
mapping = {'foo': "one"}
env = Environment(loader=loaders.DictLoader(mapping))
assert env.get_template('foo').render() == "one"
mapping['foo'] = "two"
assert env.get_template('foo').render() == "two"

def test_split_template_path(self):
assert split_template_path('foo/bar') == ['foo', 'bar']
assert split_template_path('./foo/bar') == ['foo', 'bar']
Expand Down