From 98d45228a76618fd0e4137742864fd03ddc1b402 Mon Sep 17 00:00:00 2001
From: Simon Charette <charette.s@gmail.com>
Date: Thu, 26 Mar 2015 03:19:24 -0400
Subject: [PATCH] Made sure self can't be overriden in Jinja.
---
django/template/backends/jinja2.py | 2 +-
tests/template_backends/jinja2/template_backends/self.html | 1 +
tests/template_backends/templates/template_backends/self.html | 1 +
tests/template_backends/test_dummy.py | 5 +++++
4 files changed, 8 insertions(+), 1 deletion(-)
create mode 100644 tests/template_backends/jinja2/template_backends/self.html
create mode 100644 tests/template_backends/templates/template_backends/self.html
diff --git a/django/template/backends/jinja2.py b/django/template/backends/jinja2.py
index b26cb39..0863773 100644
a
|
b
|
class Template(object):
|
60 | 60 | context['request'] = request |
61 | 61 | context['csrf_input'] = csrf_input_lazy(request) |
62 | 62 | context['csrf_token'] = csrf_token_lazy(request) |
63 | | return self.template.render(**context) |
| 63 | return self.template.render(context) |
diff --git a/tests/template_backends/jinja2/template_backends/self.html b/tests/template_backends/jinja2/template_backends/self.html
new file mode 100644
index 0000000..e3125de
diff --git a/tests/template_backends/templates/template_backends/self.html b/tests/template_backends/templates/template_backends/self.html
new file mode 100644
index 0000000..e3125de
diff --git a/tests/template_backends/test_dummy.py b/tests/template_backends/test_dummy.py
index b529b70..943c76c 100644
a
|
b
|
class TemplateStringsTests(SimpleTestCase):
|
93 | 93 | template = self.engine.get_template('template_backends/hello.html') |
94 | 94 | content = template.render({'name': 'Jérôme'}) |
95 | 95 | self.assertEqual(content, "Hello Jérôme!\n") |
| 96 | |
| 97 | def test_context_self(self): |
| 98 | template = self.engine.get_template('template_backends/self.html') |
| 99 | content = template.render({'self': 'Self'}) |
| 100 | self.assertEqual(content, "Self\n") |