Skip to content

Commit

Permalink
fix liquid template argument parsing
Browse files Browse the repository at this point in the history
	- fixes undefined arguments in shortcodes and potentially other uses
	- fixes #2348 and #2154
  • Loading branch information
epelc authored and zachleat committed May 6, 2022
1 parent 6ea1944 commit baca2ad
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Engines/Liquid.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,16 @@ class Liquid extends TemplateEngine {
line: 1,
col: 1 }*/
if (arg.type.indexOf("ignore:") === -1) {
argArray.push(await engine.evalValue(arg.value, scope));
// Push the promise into an array instead of awaiting it here.
// This forces the promises to run in order with the correct scope value for each arg.
// Otherwise they run out of order and can lead to undefined values for arguments in layout template shortcodes.
argArray.push(engine.evalValue(arg.value, scope));
}
arg = lexer.next();
}
}

return argArray;
return await Promise.all(argArray);
}

static _normalizeShortcodeScope(ctx) {
Expand Down

0 comments on commit baca2ad

Please sign in to comment.