Opened 7 years ago

Closed 7 years ago

#29060 closed Bug (fixed)

Make {% firstof %} assign '' to the asvar if all inputs are false

Reported by: Roger Gammans Owned by: nobody
Component: Template system Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Roger Gammans)

I have verified this in version 1.8 and 2.0.

firstof with an 'as' clause doesn't set; or reset the target context variable if all parameters are false. I would expect the context variable to be set to None or the empty string to match the replacement mode behaviour of the tag.

As per summary.; Will add reference to a PR 9618 ( https://github.com/django/django/pull/9618 ) has a fix and example unittest

Change History (3)

comment:1 by Roger Gammans, 7 years ago

Description: modified (diff)

comment:2 by Tim Graham, 7 years ago

Summary: FirstOf with an 'as' clause has confusing behaviour in all false caseMake {% firstof %} assign '' to the asvar if all inputs are false
Triage Stage: UnreviewedReady for checkin

comment:3 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: newclosed

In d0b44c44:

Fixed #29060 -- Made {% firstof %} assign to the asvar if all inputs are false.

Note: See TracTickets for help on using tickets.
Back to Top