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
e369dc28
Kaydet (Commit)
e369dc28
authored
Şub 24, 2013
tarafından
Preston Holmes
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #832 from chrismedrela/ticket19890
Fixed #19890 -- ifchanged templatetag rendered its content twice
üst
d5462596
636c45fc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
defaulttags.py
django/template/defaulttags.py
+3
-2
tests.py
tests/regressiontests/templates/tests.py
+12
-0
No files found.
django/template/defaulttags.py
Dosyayı görüntüle @
e369dc28
...
...
@@ -223,6 +223,7 @@ class IfChangedNode(Node):
if
self
not
in
state_frame
:
state_frame
[
self
]
=
None
nodelist_true_output
=
None
try
:
if
self
.
_varlist
:
# Consider multiple parameters. This automatically behaves
...
...
@@ -230,13 +231,13 @@ class IfChangedNode(Node):
compare_to
=
[
var
.
resolve
(
context
,
True
)
for
var
in
self
.
_varlist
]
else
:
# The "{% ifchanged %}" syntax (without any variables) compares the rendered output.
compare_to
=
self
.
nodelist_true
.
render
(
context
)
compare_to
=
nodelist_true_output
=
self
.
nodelist_true
.
render
(
context
)
except
VariableDoesNotExist
:
compare_to
=
None
if
compare_to
!=
state_frame
[
self
]:
state_frame
[
self
]
=
compare_to
return
self
.
nodelist_true
.
render
(
context
)
return
nodelist_true_output
or
self
.
nodelist_true
.
render
(
context
)
# render true block if not already rendered
elif
self
.
nodelist_false
:
return
self
.
nodelist_false
.
render
(
context
)
return
''
...
...
tests/regressiontests/templates/tests.py
Dosyayı görüntüle @
e369dc28
...
...
@@ -441,6 +441,18 @@ class Templates(TestCase):
output1
=
template
.
render
(
Context
({
'foo'
:
range
(
3
),
'get_value'
:
lambda
:
next
(
gen1
)}))
self
.
assertEqual
(
output1
,
'[0,1,2,3]'
,
'Expected [0,1,2,3] in first template, got {0}'
.
format
(
output1
))
def
test_ifchanged_render_once
(
self
):
""" Test for ticket #19890. The content of ifchanged template tag was
rendered twice."""
template
=
Template
(
'{
%
ifchanged
%
}{{ gen.next }}{
%
endifchanged
%
}'
)
def
gen
():
for
i
in
xrange
(
1
,
10
):
yield
'iteration no
%
d'
%
i
output
=
template
.
render
(
Context
({
'gen'
:
gen
()}))
self
.
assertEqual
(
output
,
'iteration no 1'
)
def
test_templates
(
self
):
template_tests
=
self
.
get_template_tests
()
filter_tests
=
filters
.
get_filter_tests
()
...
...
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