#27022: some DjangoTemplates builtin tags misparse lack of whitespace between
variable name and boolean operator in arguments
-------------------------+-------------------------------------------------
Reporter: cowbert | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.10
Template system | Keywords: tags, arguments, operators,
Severity: Normal | whitespace
Triage Stage: | Has patch: 0
Unreviewed |
Easy pickings: 0 | UI/UX: 0
-------------------------+-------------------------------------------------
The `django.DjangoTemplates` template backend is unable to parse a
comparison operator when there is no whitespace around the operator using
builtin tag `if`:
{{{#!python
{% if foo=='bar' %}
<!-- do something -->
{% endif %}
}}}
raises:
{{{
TemplateSyntaxError at url
Could not parse the remainder: '=='bar'' from 'foo=='bar''
}}}
At least one space is required on both sides of the `==` operator (So `foo
=='bar'` and `foo== 'bar'` throws `Could not parse the remainder:
'=='bar'' from '=='bar''` and `Could not parse the remainder: '==' from
'foo=='`, respectively). More than one space is acceptable.
This seems to affect the following boolean operators: `==`, `!=`, `<`,
`>`, `<=`, `>=`. My guess is the boolean expression tokenizer in
DjangoTemplates first tries split(' ') then ultimately evals ![0]![1]![2]
(but I haven't actually looked at the source to verify this).
--
Ticket URL: <https://code.djangoproject.com/ticket/27022>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.d15f222c0d2a29557b56b1842613a418%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.