Skip to content

Commit baca2ad

Browse files
epelczachleat
authored andcommitted
fix liquid template argument parsing
- fixes undefined arguments in shortcodes and potentially other uses - fixes #2348 and #2154
1 parent 6ea1944 commit baca2ad

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Engines/Liquid.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,16 @@ class Liquid extends TemplateEngine {
116116
line: 1,
117117
col: 1 }*/
118118
if (arg.type.indexOf("ignore:") === -1) {
119-
argArray.push(await engine.evalValue(arg.value, scope));
119+
// Push the promise into an array instead of awaiting it here.
120+
// This forces the promises to run in order with the correct scope value for each arg.
121+
// Otherwise they run out of order and can lead to undefined values for arguments in layout template shortcodes.
122+
argArray.push(engine.evalValue(arg.value, scope));
120123
}
121124
arg = lexer.next();
122125
}
123126
}
124127

125-
return argArray;
128+
return await Promise.all(argArray);
126129
}
127130

128131
static _normalizeShortcodeScope(ctx) {

0 commit comments

Comments
 (0)