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
8625c7aa
Kaydet (Commit)
8625c7aa
authored
Agu 30, 2013
tarafından
Preston Timmons
Kaydeden (comit)
Tim Graham
Eyl 06, 2013
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #16096 -- Added origin attribute to template instances.
Thanks jdunck for the suggestion.
üst
e1266e50
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
1 deletion
+54
-1
base.py
django/template/base.py
+1
-0
api.txt
docs/ref/templates/api.txt
+36
-1
1.7.txt
docs/releases/1.7.txt
+4
-0
tests.py
tests/template_tests/tests.py
+13
-0
No files found.
django/template/base.py
Dosyayı görüntüle @
8625c7aa
...
...
@@ -124,6 +124,7 @@ class Template(object):
origin
=
StringOrigin
(
template_string
)
self
.
nodelist
=
compile_string
(
template_string
,
origin
)
self
.
name
=
name
self
.
origin
=
origin
def
__iter__
(
self
):
for
node
in
self
.
nodelist
:
...
...
docs/ref/templates/api.txt
Dosyayı görüntüle @
8625c7aa
...
...
@@ -759,10 +759,45 @@ Django uses the template loaders in order according to the
:setting:`TEMPLATE_LOADERS` setting. It uses each loader until a loader finds a
match.
.. currentmodule:: django.template
Template origin
~~~~~~~~~~~~~~~
.. versionadded:: 1.7
When :setting:`TEMPLATE_DEBUG` is ``True`` template objects will have an
``origin`` attribute depending on the source they are loaded from.
.. class:: loader.LoaderOrigin
Templates created from a template loader will use the
``django.template.loader.LoaderOrigin`` class.
.. attribute:: name
The path to the template as returned by the template loader.
For loaders that read from the file system, this is the full
path to the template.
.. attribute:: loadname
The relative path to the template as passed into the
template loader.
.. class:: StringOrigin
Templates created from a ``Template`` class will use the
``django.template.StringOrigin`` class.
.. attribute:: source
The string used to create the template.
The ``render_to_string`` shortcut
===================================
.. function::
django.template.
loader.render_to_string(template_name, dictionary=None, context_instance=None)
.. function:: loader.render_to_string(template_name, dictionary=None, context_instance=None)
To cut down on the repetitive nature of loading and rendering
templates, Django provides a shortcut function which largely
...
...
docs/releases/1.7.txt
Dosyayı görüntüle @
8625c7aa
...
...
@@ -272,6 +272,10 @@ Templates
* It is now possible to :ttag:`include` templates recursively.
* Template objects now have an origin attribute set when
:setting:`TEMPLATE_DEBUG` is ``True``. This allows template origins to be
inspected and logged outside of the ``django.template`` infrastructure.
Backwards incompatible changes in 1.7
=====================================
...
...
tests/template_tests/tests.py
Dosyayı görüntüle @
8625c7aa
...
...
@@ -236,6 +236,19 @@ class TemplateLoaderTests(TestCase):
loader
.
template_source_loaders
=
old_loaders
settings
.
TEMPLATE_DEBUG
=
old_td
def
test_loader_origin
(
self
):
with
self
.
settings
(
TEMPLATE_DEBUG
=
True
):
template
=
loader
.
get_template
(
'login.html'
)
self
.
assertEqual
(
template
.
origin
.
loadname
,
'login.html'
)
def
test_string_origin
(
self
):
with
self
.
settings
(
TEMPLATE_DEBUG
=
True
):
template
=
Template
(
'string template'
)
self
.
assertEqual
(
template
.
origin
.
source
,
'string template'
)
def
test_debug_false_origin
(
self
):
template
=
loader
.
get_template
(
'login.html'
)
self
.
assertEqual
(
template
.
origin
,
None
)
def
test_include_missing_template
(
self
):
"""
...
...
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