From baca2ad9f19311602ad4d3e08fbb600c57db41b8 Mon Sep 17 00:00:00 2001 From: Ed Pelc Date: Fri, 6 May 2022 10:25:19 -0400 Subject: [PATCH] fix liquid template argument parsing - fixes undefined arguments in shortcodes and potentially other uses - fixes #2348 and #2154 --- src/Engines/Liquid.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Engines/Liquid.js b/src/Engines/Liquid.js index cc26c2560..87ab9d627 100644 --- a/src/Engines/Liquid.js +++ b/src/Engines/Liquid.js @@ -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) {