Skip to content

Commit

Permalink
Actually use the Jinja2 template backend
Browse files Browse the repository at this point in the history
Refs #1881.
  • Loading branch information
matthiask committed Feb 12, 2024
1 parent c688ce4 commit 8022782
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
5 changes: 4 additions & 1 deletion tests/panels/test_template.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from unittest import expectedFailure

import django
from django.contrib.auth.models import User
from django.template import Context, RequestContext, Template
Expand Down Expand Up @@ -135,11 +137,12 @@ def test_lazyobject_eval(self):
DEBUG=True, DEBUG_TOOLBAR_PANELS=["debug_toolbar.panels.templates.TemplatesPanel"]
)
class JinjaTemplateTestCase(IntegrationTestCase):
@expectedFailure
def test_django_jinja2(self):
r = self.client.get("/regular_jinja/foobar/")
self.assertContains(r, "Test for foobar (Jinja)")
self.assertContains(r, "<h3>Templates (2 rendered)</h3>")
self.assertContains(r, "<small>jinja2/basic.jinja</small>")
self.assertContains(r, "<small>basic.jinja</small>")


def context_processor(request):
Expand Down
9 changes: 9 additions & 0 deletions tests/templates/jinja2/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>{{ title }}</title>
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>
5 changes: 4 additions & 1 deletion tests/templates/jinja2/basic.jinja
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
{% extends 'base.html' %}
{% block content %}Test for {{ title }} (Jinja){% endblock %}
{% block content %}
Test for {{ title }} (Jinja)
{% for i in range(10) %}{{ i }}{% endfor %} {# Jinja2 supports range(), Django templates do not #}
{% endblock %}
2 changes: 1 addition & 1 deletion tests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def json_view(request):


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


def listcomp_view(request):
Expand Down

0 comments on commit 8022782

Please sign in to comment.