Skip to content

Commit a989bec

Browse files
Fix support for latest Liquid scripting plugin (#109)
1 parent e56c0c1 commit a989bec

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing!
10+
- Fix support for latest Shopify Liquid plugin ([#109](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/109))
1111

1212
## [0.2.0] - 2022-11-25
1313

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"devDependencies": {
2929
"@prettier/plugin-php": "^0.19.2",
3030
"@prettier/plugin-pug": "^2.3.0",
31-
"@shopify/prettier-plugin-liquid": "^0.4.0",
31+
"@shopify/prettier-plugin-liquid": "^1.0.0-rc.2",
3232
"@shufo/prettier-plugin-blade": "^1.8.0",
3333
"@tailwindcss/line-clamp": "^0.3.0",
3434
"@trivago/prettier-plugin-sort-imports": "^3.3.0",

src/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,18 @@ function transformGlimmer(ast, { env }) {
346346
}
347347

348348
function transformLiquid(ast, { env }) {
349+
/** @param {{name: string | {type: string, value: string}[]}} node */
350+
function isClassAttr(node) {
351+
if (Array.isArray(node.name)) {
352+
return node.name.every((n) => n.type === 'TextNode' && n.value === 'class');
353+
}
354+
355+
return node.name === 'class'
356+
}
357+
349358
visit(ast, {
350359
AttrSingleQuoted(node, _parent, _key, _index, meta) {
351-
if (node.name !== "class") {
360+
if (!isClassAttr(node)) {
352361
return;
353362
}
354363

@@ -357,7 +366,7 @@ function transformLiquid(ast, { env }) {
357366
},
358367

359368
AttrDoubleQuoted(node, _parent, _key, _index, meta) {
360-
if (node.name !== "class") {
369+
if (!isClassAttr(node)) {
361370
return;
362371
}
363372

0 commit comments

Comments
 (0)