twig.js icon indicating copy to clipboard operation
twig.js copied to clipboard

Issue when using ternary operator to output content

Open cataem opened this issue 1 year ago • 1 comments

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.

cataem avatar Jul 09 '24 10:07 cataem

Hi @cataem, good find!

Here are the examples

TwigPHP example twig.js example

antoineveldhoven avatar Jun 04 '25 19:06 antoineveldhoven