#31915: Allow load template tag before extends tag
-------------------------------------------+------------------------
Reporter: Jann Haber | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: master
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 |
-------------------------------------------+------------------------
Currently the extends template tag always needs to be the first template
tag used in a template (if it is used at all). In the extends tag, it is
possible to use the built-in template tags. For example, with Django 3.0,
we have been using different base templates depending on if a request was
an ajax request or not:
{{{
{% extends request.is_ajax|yesno:"base_ajax.html,base.html" %}
}}}
Once the is_ajax method is removed from the request objects, this is not
possible anymore. A new template tag for "is_ajax" could be created (like
{{{ {% extends request|is_ajax|yesno... %} }}}), but it is not possible to
load it before extends, since extends always needs to be the first
template tag. The only possible workaround I see to achieve the same
behaviour, is to create a context processor, however this will be
processed for all requests, even the ones that don't need this feature.
All in all, I am requesting to allow load template tags before "extends".
--
Ticket URL: <https://code.djangoproject.com/ticket/31915>
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/048.ce3d1dbbc7243d8313789dc558118945%40djangoproject.com.