[Django] #33329: Allow more whitespace control on template tags

44 views
Skip to first unread message

Django

unread,
Nov 29, 2021, 5:21:32 AM11/29/21
to django-...@googlegroups.com
#33329: Allow more whitespace control on template tags
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
christopherpickering |
Type: New | Status: new
feature |
Component: Template | Version: 3.2
system | Keywords: space control
Severity: Normal | template
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When putting template tags inside of html attributes the surrounding
whitespace is not removed.

For example a readable template

{{{
<input value="{% if a %}
this
{% else %}
that
{% endif %}">
}}}

It not parsed onto a single line, which is needed. How about adding the
option `-%}` to remove whitespace between the tag end and contents?

--
Ticket URL: <https://code.djangoproject.com/ticket/33329>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 29, 2021, 5:34:30 AM11/29/21
to django-...@googlegroups.com
#33329: Allow more whitespace control on template tags
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
christopherpickering |
Type: New feature | Status: closed
Component: Template system | Version: 3.2
Severity: Normal | Resolution: invalid
Keywords: space control | Triage Stage:
template | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

Thanks for this ticket, however there is no need for a new syntax, you can
use
[https://docs.djangoproject.com/en/3.2/ref/templates/builtins/#spaceless
{% spaceless %}] for removing whitespace in rendered HTML.

--
Ticket URL: <https://code.djangoproject.com/ticket/33329#comment:1>

Django

unread,
Nov 29, 2021, 6:02:15 AM11/29/21
to django-...@googlegroups.com
#33329: Allow more whitespace control on template tags
-------------------------------------+-------------------------------------
Reporter: sur.la.route | Owner: nobody

Type: New feature | Status: closed
Component: Template system | Version: 3.2
Severity: Normal | Resolution: invalid
Keywords: space control | Triage Stage:
template | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by sur.la.route):

Does that remove space inside attributes as well? Not just in surrounding
html?

--
Ticket URL: <https://code.djangoproject.com/ticket/33329#comment:2>

Django

unread,
Nov 29, 2021, 7:40:39 AM11/29/21
to django-...@googlegroups.com
#33329: Allow more whitespace control on template tags
-------------------------------------+-------------------------------------
Reporter: sur.la.route | Owner: nobody
Type: New feature | Status: closed
Component: Template system | Version: 3.2
Severity: Normal | Resolution: invalid
Keywords: space control | Triage Stage:
template | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

Replying to [comment:2 sur.la.route]:


> Does that remove space inside attributes as well? Not just in
surrounding html?

You can use `spaceless` around the `value`, e.g.
{{{
<input value="{% spaceless %}{% if a %}


this
{% else %}
that

{% endif %}{% endspaceless %}">
}}}

Please use one of
[https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels
support channels] if you have further questions.

--
Ticket URL: <https://code.djangoproject.com/ticket/33329#comment:3>

Reply all
Reply to author
Forward
0 new messages