Deprecate length_is template filter in favor of length.
The length_is
template filter is a vestige from the days of the {% ifequal %}
and {% ifnotequal %}
tags before {% if %}
arrived with support for comparison with operators. Even the example in the documentation (see here) is poor: {{ value|length_is:"4" }}
will only return one of three possible values - True
, False
, or ""
, the empty string being for errors in the provided values.
It seems to me that it would be better to encourage use of the length
template filter with the {% if %}
template tag which can provide more flexibility:
{# Before: #}
{% if value|length_is:"4" %}...{% endif %}
{{ value|length_is:"4" }} ← This is of dubious use given the restricted set of possible output values.
{# After: #}
{% if value|length == 4 %}...{% endif %}
{% if value|length == 4 %}True{% else %}False{% endif %} ← Much clearer but also allows customising the output values.
Change History
(6)
Triage Stage: |
Unreviewed → Accepted
|
Description: |
modified (diff)
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
PR