Skip to content

Commit bbe7ccf

Browse files
committed
Actually use the Jinja2 template backend
Refs #1881.
1 parent 2b07905 commit bbe7ccf

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

tests/panels/test_template.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from unittest import expectedFailure
2+
13
import django
24
from django.contrib.auth.models import User
35
from django.template import Context, RequestContext, Template
@@ -135,11 +137,12 @@ def test_lazyobject_eval(self):
135137
DEBUG=True, DEBUG_TOOLBAR_PANELS=["debug_toolbar.panels.templates.TemplatesPanel"]
136138
)
137139
class JinjaTemplateTestCase(IntegrationTestCase):
140+
@expectedFailure
138141
def test_django_jinja2(self):
139142
r = self.client.get("/regular_jinja/foobar/")
140143
self.assertContains(r, "Test for foobar (Jinja)")
141144
self.assertContains(r, "<h3>Templates (2 rendered)</h3>")
142-
self.assertContains(r, "<small>jinja2/basic.jinja</small>")
145+
self.assertContains(r, "<small>basic.jinja</small>")
143146

144147

145148
def context_processor(request):

tests/templates/jinja2/base.html

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>{{ title }}</title>
5+
</head>
6+
<body>
7+
{% block content %}{% endblock %}
8+
</body>
9+
</html>

tests/templates/jinja2/basic.jinja

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
{% extends 'base.html' %}
2-
{% block content %}Test for {{ title }} (Jinja){% endblock %}
2+
{% block content %}
3+
Test for {{ title }} (Jinja)
4+
{% for i in range(10) %}{{ i }}{% endfor %} {# Jinja2 supports range(), Django templates do not #}
5+
{% endblock %}

tests/views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def json_view(request):
4848

4949

5050
def regular_jinjia_view(request, title):
51-
return render(request, "jinja2/basic.jinja", {"title": title})
51+
return render(request, "basic.jinja", {"title": title}, using="jinja2")
5252

5353

5454
def listcomp_view(request):

0 commit comments

Comments
 (0)