Skip to content

Commit

Permalink
Add jinja2 template to example app.
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-schilling committed Feb 18, 2024
1 parent 8022782 commit d49a2d0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
8 changes: 7 additions & 1 deletion example/settings.py
Expand Up @@ -41,6 +41,12 @@
STATIC_URL = "/static/"

TEMPLATES = [
{
"NAME": "jinja2",
"BACKEND": "django.template.backends.jinja2.Jinja2",
"APP_DIRS": True,
"DIRS": [os.path.join(BASE_DIR, "example", "templates", "jinja2")],
},
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": True,
Expand All @@ -54,7 +60,7 @@
"django.contrib.messages.context_processors.messages",
],
},
}
},
]

USE_TZ = True
Expand Down
1 change: 1 addition & 0 deletions example/templates/index.html
Expand Up @@ -9,6 +9,7 @@
<h1>Index of Tests</h1>
{% cache 10 index_cache %}
<ul>
<li><a href="/jinja/">Jinja2</a></li>
<li><a href="/jquery/">jQuery 3.3.1</a></li>
<li><a href="/mootools/">MooTools 1.6.0</a></li>
<li><a href="/prototype/">Prototype 1.7.3.0</a></li>
Expand Down
11 changes: 11 additions & 0 deletions example/templates/jinja2/index.jinja
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>jinja Test</title>
</head>
<body>
<h1>jinja Test</h1>
{% for i in range(10) %}{{ i }}{% endfor %} {# Jinja2 supports range(), Django templates do not #}
</body>
</html>
4 changes: 4 additions & 0 deletions example/urls.py
Expand Up @@ -6,6 +6,10 @@

urlpatterns = [
path("", TemplateView.as_view(template_name="index.html"), name="home"),
path(
"jinja/",
TemplateView.as_view(template_name="index.jinja", template_engine="jinja2"),
),
path("jquery/", TemplateView.as_view(template_name="jquery/index.html")),
path("mootools/", TemplateView.as_view(template_name="mootools/index.html")),
path("prototype/", TemplateView.as_view(template_name="prototype/index.html")),
Expand Down

0 comments on commit d49a2d0

Please sign in to comment.