partialdef tag embedded in verbatim tag is treated as the source property for that named partial
Although partial
and partialdef
are correctly ignored when rendered if embedded within {% verbatim %}
, the PartialTemplate.source
property is fooled, potentially impacting error reporting:
@setup(
{
"partial_embedded_in_verbatim": (
"{% verbatim %}\n"
"{% partialdef testing-name %}\n"
"{% endverbatim %}\n"
"{% partialdef testing-name %}\n"
"<p>Content</p>\n"
"{% endpartialdef %}\n"
),
},
test_once=True,
)
def test_partial_template_embedded_in_verbatim(self):
template = self.engine.get_template("partial_embedded_in_verbatim")
partial_template = template.extra_data["partials"]["testing-name"]
self.assertIn("Content", partial_template.source)
======================================================================
FAIL: test_partial_template_embedded_in_verbatim (template_tests.syntax_tests.test_partials.PartialTagTests.test_partial_template_embedded_in_verbatim)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/jwalls/django/django/test/utils.py", line 458, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/jwalls/django/tests/template_tests/utils.py", line 58, in inner
func(self)
File "/Users/jwalls/django/tests/template_tests/syntax_tests/test_partials.py", line 676, in test_partial_template_embedded_in_verbatim
self.assertIn("Content", partial_template.source)
AssertionError: 'Content' not found in ''
The use case presented here isn't very serious, so I'm loathe to really mark this as a release blocker, but as it's a new feature and that's our process, and I'm not sure if there are other more important uses of the source property, I'll start there.
Change History
(13)
Description: |
modified (diff)
|
Summary: |
partialdef tag embedded in verbatim tag is treated as the source attribute for that named partial → partialdef tag embedded in verbatim tag is treated as the source property for that named partial
|
Cc: |
Carlton Gibson Farhan Ali added
|
Keywords: |
partials added
|
Triage Stage: |
Unreviewed → Accepted
|
Owner: |
set to Farhan Ali
|
Status: |
new → assigned
|
Description: |
modified (diff)
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
Thank you Jacob, I agree that we should treat as release blocker.