summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jinja2/loaders.py2
-rw-r--r--jinja2/testsuite/loader.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/jinja2/loaders.py b/jinja2/loaders.py
index c90bbe7..bd40929 100644
--- a/jinja2/loaders.py
+++ b/jinja2/loaders.py
@@ -274,7 +274,7 @@ class DictLoader(BaseLoader):
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):
diff --git a/jinja2/testsuite/loader.py b/jinja2/testsuite/loader.py
index f62ec92..9368698 100644
--- a/jinja2/testsuite/loader.py
+++ b/jinja2/testsuite/loader.py
@@ -93,6 +93,13 @@ class LoaderTestCase(JinjaTestCase):
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']