Skip to content

Commit 77ae2be

Browse files
committed
Sort all call expressions in Twig using tailwindFunctions
1 parent 8c5c660 commit 77ae2be

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ function transformMarko(ast: any, { env }: TransformerContext) {
831831
}
832832

833833
function transformTwig(ast: any, { env, changes }: TransformerContext) {
834-
let { staticAttrs } = env.customizations
834+
let { staticAttrs, functions } = env.customizations
835835

836836
for (let child of ast.expressions ?? []) {
837837
transformTwig(child, { env, changes })
@@ -844,6 +844,14 @@ function transformTwig(ast: any, { env, changes }: TransformerContext) {
844844
meta.sortTextNodes = true
845845
},
846846

847+
CallExpression(node, _path, meta) {
848+
if (node.callee.type !== 'MemberExpression') return
849+
if (!node.callee.property) return
850+
if (!functions.has(node.callee.property.name)) return
851+
852+
meta.sortTextNodes = true
853+
},
854+
847855
StringLiteral(node, path, meta) {
848856
if (!meta.sortTextNodes) {
849857
return

0 commit comments

Comments
 (0)