Skip to content

Inline if should return undefined if there's no else #1509

Description

@romaricpascal

Currently, inline if expressions are compiled to return an empty string in the absence of an else.

Jinja's templating documentation specifies that an inline if expression should return an Undefined object.

For parity with Jinja, seems Nunjucks inline ifs should also evaluate to undefined in the absence of an else. Both '' and undefined are falsy, but some code may require to differenciate between undefined (no value was given) and '' (an empty string was given). Such code gets easily broken if called with <SOMETHING> if <CONDITION> as you'd expect undefined but get ''.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions