prettier-plugin-liquid icon indicating copy to clipboard operation
prettier-plugin-liquid copied to clipboard

Formatting liquid templates for non-HTML content

Open amit777 opened this issue 10 months ago • 0 comments

Is your feature request related to a problem? Please describe. We are using liquid templates within text templates that are not HTML (ie, for text email content). When we use the prettier plugin, multiple whitespace and linebreaks get removed.

Describe the solution you'd like I would love to be able to pass a config option like "textTemplate: true" to make prettier just format the liquid tags and not the text between them.

Describe alternatives you've considered Have tried looking for other prettier plugins that support liquid but this seems to be the standard one.

Checklist

  • [x] I have checked and made sure that the proposal adheres to this plugin's principles

I believe the extra whitespace is meaningful in text templates. I've read through this link as well: https://github.com/Shopify/prettier-plugin-liquid/blob/main/docs/whitespace-handling.md

I'm not sure if this prettier module is supposed to be specialized for HTML?

Additional context Here is an example before/after for a template that I'm looking for:

Before: {% if foo=="bar" %}FOO SPACE{%endif%}

After (current): {% if foo == "bar" %}FOO SPACE{% endif %}

Desired Output (no removal of the spaces in between FOO and SPACE but the spacing within a liquid tag are correct): {% if foo == "bar" %}FOO SPACE{% endif %}

amit777 avatar Aug 24 '23 23:08 amit777