#32290: TemplateNotFound if relative path passed to {% include %} in variable
------------------------------------------+------------------------
               Reporter:  Peter Inglesby  |          Owner:  nobody
                   Type:  Uncategorized   |         Status:  new
              Component:  Uncategorized   |        Version:  3.1
               Severity:  Normal          |       Keywords:
           Triage Stage:  Unreviewed      |      Has patch:  0
    Needs documentation:  0               |    Needs tests:  0
Patch needs improvement:  0               |  Easy pickings:  0
                  UI/UX:  0               |
------------------------------------------+------------------------
 If you pass a template path as string literal to `{% include %}`, the
 template path can begin with eg `./`, which is then resolved.

 However, if you pass a template path in a variable to `{% include %}`, the
 `./` is not resolved and Django raises `TemplateNotFound`.

 For instance, I have a template for rendering Bootstrap tab panels:

 {{{
 <div
       class="tab-pane fade p-4"
       id="{{ tab_name }}"
       role="tabpanel"
       aria-labelledby="{{ tab_name }}-tab"
 >
   {% include template_path %}
 </div>
 }}}

 This works:

 {{{
 {% include "./_bootstrap_panel.html" with tab_name="search-results"
 template_name="myapp/_search_results.html" %}
 }}}

 This doesn't:

 {{{
 {% include "./_bootstrap_panel.html" with tab_name="search-results"
 template_name="./_search_results.html" %}
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32290>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.55220c21f3e67da2c139c71d53e235f8%40djangoproject.com.

Reply via email to