diff options
-rw-r--r-- | docs/templates.rst | 2 | ||||
-rw-r--r-- | jinja2/loaders.py | 2 | ||||
-rw-r--r-- | jinja2/testsuite/loader.py | 7 |
3 files changed, 9 insertions, 2 deletions
diff --git a/docs/templates.rst b/docs/templates.rst index 6c8eee3..c60b27f 100644 --- a/docs/templates.rst +++ b/docs/templates.rst @@ -830,7 +830,7 @@ default. For more details about context behavior of imports and includes see :ref:`import-visibility`. From Jinja 2.2 onwards you can mark an include with ``ignore missing`` in -which case Jinja will ignore the statement if the template to be ignored +which case Jinja will ignore the statement if the template to be included does not exist. When combined with ``with`` or ``without context`` it has to be placed *before* the context visibility statement. Here some valid examples:: diff --git a/jinja2/loaders.py b/jinja2/loaders.py index 08fe872..f8e4f99 100644 --- a/jinja2/loaders.py +++ b/jinja2/loaders.py @@ -275,7 +275,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'] |