babel-plugin-transform-liquid-in-template-literals
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-alpha.0 • Public • Published

babel-plugin-transform-liquid-in-template-literals

From:

<img
    src="{{ 'affirm_logo_black.svg' | asset_url }}"
    class="affirmLogo"
/>

To:

<img
    src='{{ "affirm_logo_black.svg" | asset_url }}'
    class="affirmLogo"
/>

Why

This is useful if you are using Liquid filters inside JavaScript and using Terser for minification instead of Babel's minifier. If you don't want to keep remembering to use single quotes for html attributes to get Liquid to work inside. Then, use this plugin to take care of things for you.

Detailed Why

What ends up happening is Terser will transform the following:

input:  src="{{ 'affirm_logo_black.svg' | asset_url }}"

output: src="{{ \'affirm_logo_black.svg\' | asset_url }}"

        ^^^^ Liquid will see that the value is incorrect

But if the code is set like so:

input:  src='{{ "affirm_logo_black.svg" | asset_url }}'

output: src=\'{{ "affirm_logo_black.svg" | asset_url }}\'

Then, Liquid can still process the value properly.

Package Sidebar

Install

npm i babel-plugin-transform-liquid-in-template-literals

Weekly Downloads

0

Version

0.0.1-alpha.0

License

MIT

Unpacked Size

129 kB

Total Files

20

Last publish

Collaborators

  • weffe