From 5cae4358dc354a4ce4ee9875dde29d3622efb39f Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Mon, 9 May 2022 15:43:16 -0500 Subject: [PATCH] Cherry pick of 4c710d68965b0d0d19d9a6e7e76b1004f4e6e4e1 --- test/TemplateTest.js | 39 +++++++++++++++++++ ...ithLiquidShortcodeMultipleArguments.liquid | 9 +++++ 2 files changed, 48 insertions(+) create mode 100644 test/stubs/templateWithLiquidShortcodeMultipleArguments.liquid diff --git a/test/TemplateTest.js b/test/TemplateTest.js index 11aba5cfa..c25802cb9 100644 --- a/test/TemplateTest.js +++ b/test/TemplateTest.js @@ -293,6 +293,45 @@ test("One Layout (_layoutContent deprecated but supported)", async (t) => { t.is(data.keylayout, "valuelayout"); }); +test("Liquid shortcode with multiple arguments(issue #2348)", async (t) => { + // NOTE issue #2348 was only active when you were processing multiple templates at the same time. + + let eleventyConfig = new TemplateConfig(); + eleventyConfig.userConfig.addShortcode("simplelink", function (text, url) { + return `${text} (${url})`; + }); + + let dataObj = new TemplateData("./test/stubs/", eleventyConfig); + + let tmpl = getNewTemplate( + "./test/stubs/templateWithLiquidShortcodeMultipleArguments.liquid", + "./test/stubs/", + "dist", + dataObj, + null, + eleventyConfig + ); + + t.is( + (await tmpl.getFrontMatter()).data[tmpl.config.keys.layout], + "layoutLiquid.liquid" + ); + + let data = await tmpl.getData(); + t.is(data[tmpl.config.keys.layout], "layoutLiquid.liquid"); + + t.is( + normalizeNewLines(cleanHtml(await tmpl.renderLayout(tmpl, data))), + `
+

Hello.

+ world (/somepage) +
` + ); + + t.is(data.keymain, "valuemain"); + t.is(data.keylayout, "valuelayout"); +}); + test("One Layout (liquid test)", async (t) => { let eleventyConfig = new TemplateConfig(); let dataObj = new TemplateData("./test/stubs/", eleventyConfig); diff --git a/test/stubs/templateWithLiquidShortcodeMultipleArguments.liquid b/test/stubs/templateWithLiquidShortcodeMultipleArguments.liquid new file mode 100644 index 000000000..ca2eefe84 --- /dev/null +++ b/test/stubs/templateWithLiquidShortcodeMultipleArguments.liquid @@ -0,0 +1,9 @@ +--- +layout: layoutLiquid.liquid +keymain: valuemain +title: 'Font Aliasing, or How to Rename a Font in CSS' +permalink: /rename-font2/ +--- + +

Hello.

+{% simplelink "world", "/somepage" %} \ No newline at end of file