#36998: firstof tag doesn't require an argument when used with as var
----------------------+-------------------------------------------
Reporter: Lily | Type: Bug
Status: new | Component: Template system
Version: 6.0 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
----------------------+-------------------------------------------
The `{% firstof %}` template tag raises a `TemplateSyntaxError("'firstof'
statement requires at least one argument")` when called with no arguments.
However, when called with exactly two arguments that match the variable
capturing syntax (e.g. `{% firstof as foo %}`) no error is raised and the
`FirstOfNode` is returned with an empty `vars` list (and an `asvar` of
e.g. `foo`). It would be consistent to raise a
`TemplateSyntaxError("'firstof' statement requires at least one argument
before 'as'")` here.
This was discovered when [
https://github.com/LilyFirefly/django-rusty-
templates/pull/366/changes#r2971319569 re-implementing `firstof` in
django-rusty-templates].
--
Ticket URL: <
https://code.djangoproject.com/ticket/36998>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.