#35493: Allow `./` and `../` in paths when recursively including templates -------------------------------------+------------------------------------- Reporter: Gabriel Nick | Owner: Gabriel Pivovarov | Nick Pivovarov Type: Bug | Status: assigned Component: Template system | Version: 5.0 Severity: Normal | Resolution: Keywords: template | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 1 | Patch needs improvement: 0 Easy pickings: 1 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by Sarah Boyce):
* stage: Unreviewed => Accepted Comment: Relative path support was added in #26402 and recursive include support was added in #3544. I think this was missed when working on #26402, replicated. Here is my test: {{{#!diff diff --git a/tests/template_tests/syntax_tests/test_include.py b/tests/template_tests/syntax_tests/test_include.py index 3ee99b3798..6dafba5040 100644 --- a/tests/template_tests/syntax_tests/test_include.py +++ b/tests/template_tests/syntax_tests/test_include.py @@ -339,6 +339,14 @@ class IncludeTests(SimpleTestCase): .replace("\n", " ") .strip(), ) + t = engine.get_template("recursive_relative_include.html") + self.assertEqual( + "Recursion! A1 Recursion! B1 B2 B3 Recursion! C1", + t.render(Context({"comments": comments})) + .replace(" ", "") + .replace("\n", " ") + .strip(), + ) def test_include_cache(self): """ diff --git a/tests/template_tests/templates/recursive_relative_include.html b/tests/template_tests/templates/recursive_relative_include.html index e69de29bb2..ae49cc0a43 100644 --- a/tests/template_tests/templates/recursive_relative_include.html +++ b/tests/template_tests/templates/recursive_relative_include.html @@ -0,0 +1,7 @@ +Recursion! +{% for comment in comments %} + {{ comment.comment }} + {% if comment.children %} + {% include "./recursive_relative_include.html" with comments=comment.children %} + {% endif %} +{% endfor %} }}} -- Ticket URL: <https://code.djangoproject.com/ticket/35493#comment:6> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/010701900ce95043-016523ae-d7a0-42f9-8de5-6372cc68552c-000000%40eu-central-1.amazonses.com.