Shopify / prettier-plugin-liquid

Prettier Liquid/HTML plugin
https://npm.im/@shopify/prettier-plugin-liquid
MIT License
93 stars 15 forks source link

Use of secondary templating engine breaks the parser #123

Closed charlespwd closed 1 year ago

charlespwd commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

Unformatted source

<label class="[[ cssClasses.label ]] flex items-center gap-x-4 sm:gap-x-2">
  <input
    class="[[ cssClasses.checkbox ]] form-checkbox sm:text-[8px]"
    type="checkbox"

    [[# isRefined ]]
      checked
    [[/ isRefined ]]
  />

  <span class="text-[12px] uppercase">
    [[ label ]]
  </span>
</label>

Expected output

<label class="[[ cssClasses.label ]] flex items-center gap-x-4 sm:gap-x-2">
  <input
    class="[[ cssClasses.checkbox ]] form-checkbox sm:text-[8px]"
    type="checkbox"

    [[# isRefined ]]
      checked
    [[/ isRefined ]]
  />

  <span class="text-[12px] uppercase">
    [[ label ]]
  </span>
</label>

Actual output Parsing error on [[/ isRefined]] because it expects > after the /

Additional context https://shopifypartners.slack.com/archives/C4E704GBX/p1669381288592919?thread_ts=1669239070.087879&cid=C4E704GBX

tomblanchard commented 1 year ago

You can do this for a temp fix:

<label class="[[ cssClasses.label ]] flex items-center gap-x-4 sm:gap-x-2">
  <input
    class="[[ cssClasses.checkbox ]] form-checkbox sm:text-[8px]"
    type="checkbox"
    {{ '[[# isRefined ]]' }}
    checked
    {{ '[[/ isRefined ]]' }}
  >

  <span class="text-[12px] uppercase"> [[ label ]] </span>
</label>