davidodenwald/prettier-plugin-jinja-template

Doesn’t replace {{ variables }} before handing code off to sub parsers

Closed this issue · 1 comments

{% if theme_accent_color %}
<style>
:root { --accent-color: {{ theme_accent_color }} }
</style>
{% endif %}

gives

[error] SyntaxError: CssSyntaxError: Unknown word (2:28)
[error]   1 |
[error] > 2 | :root { --accent-color: {{ theme_accent_color }} }
[error]     |                            ^
[error]   3 |

This plugin doesn't support jinja inside style or script tags.
Supporting these is no priority for me.

The easiest way to fix this problem is by putting the code in a ignore block:

{% if theme_accent_color %}
  <!-- prettier-ignore-start -->
  <style>
    :root { --accent-color: {{ theme_accent_color }} }
  </style>
  <!-- prettier-ignore-end -->
{% endif %}