trivago / prettier-plugin-twig-melody

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

Support for ??? "Empty Coalesce" operator #47

Open kylecotter opened 4 years ago

kylecotter commented 4 years ago

Hi,

I'm using this with Craft CMS Twig templating and am curious how I'd go about circumventing a syntax error with the ??? operator.

I use this plugin, which it itself is based on a PR pending on the Twig repo, quite a bit.

When compiling with Prettier I get Error: ERROR: Unexpected token "?" of value "?" which occurs as an example, within a conditional such as {% if foo ??? bar %}

Obviously, it's right to throw an error as it isn't official Twig markup, but was wondering if there was a way to get past that.

Thanks a bunch for your work on this!

mandrasch commented 1 year ago

Hey, have you found a good solution? I only found out that I could use <!-- {% set id = element.myId ??? null %} --> around it to get past it, but these results in a lot of <!-- --> comments on page 🤔