Shopify / prettier-plugin-liquid

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

When using {% render %} as an attribute into <img>, the prettier add a `-`only to the closing liquid bracket of the render. #99

Closed iska31 closed 1 year ago

iska31 commented 1 year ago

Describe the bug When using {% render %} as an attribute into img tag, the prettier add a -only to the closing liquid bracket of the render. This causes the code not showing correctly into the html tag, and thus the img not being displayed.

Unformatted source

<img class="product-item__primary-image" loading="lazy" data-media-id="{{ product.featured_media.id | escape }}" sizes="{{ sizes_attribute }}" {% render 'image-attributes', image: product.featured_media, sizes: '200,300,400,500,600,700,800,900,1000,1100,1200' %}>

Expected output

<img
  class='product-item__primary-image'
  loading='lazy'
  data-media-id='{{ product.featured_media.id | escape }}'
  sizes='{{ sizes_attribute }}'
  {% render 'image-attributes',
    image: product.featured_media,
    sizes: '200,300,400,500,600,700,800,900,1000,1100,1200'
  %}
>

Actual output

<img
  class='product-item__primary-image'
  loading='lazy'
  data-media-id='{{ product.featured_media.id | escape }}'
  sizes='{{ sizes_attribute }}'
  {% render 'image-attributes',
    image: product.featured_media,
    sizes: '200,300,400,500,600,700,800,900,1000,1100,1200'
  -%}
>

Debugging information

Additional context The theme used is a paid them called Focal. The rendered snippet is not having having any issue.

charlespwd commented 1 year ago

Hmm yep that's a bug. The lack of whitespace is not meaningful in that case so we shouldn't add whitespace stripping characters to maintain the lack of whitespace.

Thanks for reporting!