Skip to content

Commit

Permalink
Fix support for latest Liquid scripting plugin (tailwindlabs#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecrypticace authored and nderscore committed Dec 11, 2022
1 parent 0945ebb commit a039f7e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -28,7 +28,7 @@
"devDependencies": {
"@prettier/plugin-php": "^0.19.2",
"@prettier/plugin-pug": "^2.3.0",
"@shopify/prettier-plugin-liquid": "^0.4.0",
"@shopify/prettier-plugin-liquid": "^1.0.0-rc.2",
"@shufo/prettier-plugin-blade": "^1.8.0",
"@tailwindcss/line-clamp": "^0.3.0",
"@trivago/prettier-plugin-sort-imports": "^3.3.0",
Expand Down
13 changes: 11 additions & 2 deletions src/index.js
Expand Up @@ -346,9 +346,18 @@ function transformGlimmer(ast, { env }) {
}

function transformLiquid(ast, { env }) {
/** @param {{name: string | {type: string, value: string}[]}} node */
function isClassAttr(node) {
if (Array.isArray(node.name)) {
return node.name.every((n) => n.type === 'TextNode' && n.value === 'class');
}

return node.name === 'class'
}

visit(ast, {
AttrSingleQuoted(node, _parent, _key, _index, meta) {
if (node.name !== "class") {
if (!isClassAttr(node)) {
return;
}

Expand All @@ -357,7 +366,7 @@ function transformLiquid(ast, { env }) {
},

AttrDoubleQuoted(node, _parent, _key, _index, meta) {
if (node.name !== "class") {
if (!isClassAttr(node)) {
return;
}

Expand Down

0 comments on commit a039f7e

Please sign in to comment.