Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
44de7218
Kaydet (Commit)
44de7218
authored
Kas 12, 2014
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added jinja2 template backend.
üst
86c75996
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
jinja2.py
django/template/backends/jinja2.py
+58
-0
No files found.
django/template/backends/jinja2.py
0 → 100644
Dosyayı görüntüle @
44de7218
import
sys
from
django.conf
import
settings
from
django.template
import
TemplateDoesNotExist
from
django.utils
import
six
from
django.utils.module_loading
import
import_string
from
jinja2
import
(
DebugUndefined
,
FileSystemLoader
,
TemplateNotFound
,
Undefined
)
from
.base
import
BaseEngine
from
.utils
import
csrf_input_lazy
,
csrf_token_lazy
class
Jinja2
(
BaseEngine
):
app_dirname
=
'jinja2'
def
__init__
(
self
,
params
):
params
=
params
.
copy
()
options
=
params
.
pop
(
'OPTIONS'
)
.
copy
()
super
(
Jinja2
,
self
)
.
__init__
(
params
)
environment
=
options
.
pop
(
'environment'
,
'jinja2.Environment'
)
environment_cls
=
import_string
(
environment
)
options
.
setdefault
(
'autoescape'
,
True
)
options
.
setdefault
(
'loader'
,
FileSystemLoader
(
self
.
template_dirs
))
options
.
setdefault
(
'auto_reload'
,
settings
.
DEBUG
)
options
.
setdefault
(
'undefined'
,
DebugUndefined
if
settings
.
DEBUG
else
Undefined
)
self
.
env
=
environment_cls
(
**
options
)
def
from_string
(
self
,
template_code
):
return
Template
(
self
.
env
.
from_string
(
template_code
))
def
get_template
(
self
,
template_name
):
try
:
return
Template
(
self
.
env
.
get_template
(
template_name
))
except
TemplateNotFound
as
exc
:
six
.
reraise
(
TemplateDoesNotExist
,
TemplateDoesNotExist
(
exc
.
args
),
sys
.
exc_info
()[
2
])
class
Template
(
object
):
def
__init__
(
self
,
template
):
self
.
template
=
template
def
render
(
self
,
context
=
None
,
request
=
None
):
if
context
is
None
:
context
=
{}
if
request
is
not
None
:
context
[
'request'
]
=
request
context
[
'csrf_input'
]
=
csrf_input_lazy
(
request
)
context
[
'csrf_token'
]
=
csrf_token_lazy
(
request
)
return
self
.
template
.
render
(
**
context
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment