trivago / prettier-plugin-twig-melody

Code formatting plugin for Prettier which can handle Twig/Melody templates
Apache License 2.0
157 stars 35 forks source link

Parentheses is removed around expression after a null-coalescing operator #62

Open andersaloof opened 4 years ago

andersaloof commented 4 years ago

Formating the following code:

{% set palette = palette ?? (entry is defined and entry.type.handle in ['frontpage'] ? 'white' : null) %}

Results in this:

{% set palette = palette ?? entry is defined and entry.type.handle in ['frontpage'] ? 'white' : null %}

This causes Twig to throw the following exception:

Twig Syntax Error – Twig\Error\SyntaxError
The "defined" test only works with simple variables.