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

Bug: single/double quote conversion breaks with strings containing quotes #24

Closed chasegiunta closed 4 years ago

chasegiunta commented 4 years ago

Here's an example to make sense of:

{% set teamName = teamName|replace("College - Women's", "- Women's") %}

will format to

{% set teamName = teamName | replace('College - Women's', '- Women's') %}

The apostrophe in Women's is breaking our formatting here. Is it possible to detect ' or "characters inside our quotes and ignore the quote conversion, similar to how the detection is done in #21 with #{ and double quotes?

twbartel commented 4 years ago

Hey Chase, thanks, will take a look.

twbartel commented 4 years ago

There is a fix in v0.3.1. Can you have a look?

chasegiunta commented 4 years ago

@twbartel That works, thanks!

Worth noting for future references that for those of us using VS Code, after updating prettier-plugin-twig-melody, VS Code needs a full restart to start using the updated version.

twbartel commented 4 years ago

Yeah, I noticed that, too. It's a bit annoying.