Skip to content

Issue when using ternary operator to output content #894

Open
@cataem

Description

@cataem

Hi. I encountered this weird issue that I don't seem to find anywhere being mentioned.

{% set test2 = 'text 2' %}
{{ dump(test1) }}
{{ test1 ? test1 : test2 }}

This does not render any text. If test1 was set, it would output test1, as expected.

This does output text 2:
{{ test1 ?: test2 }}

Tried this on 1.17.1 as well.
PHP twig renders as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions