Skip to content

Commit 880255e

Browse files
committed
Cherry pick #2369 (comment)
1 parent 5cae435 commit 880255e

6 files changed

+41
-48
lines changed

test/EleventyTest.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const Eleventy = require("../src/Eleventy");
33
const EleventyWatchTargets = require("../src/EleventyWatchTargets");
44
const TemplateConfig = require("../src/TemplateConfig");
55
const DateGitLastUpdated = require("../src/Util/DateGitLastUpdated");
6+
const normalizeNewLines = require("./Util/normalizeNewLines");
67

78
test("Eleventy, defaults inherit from config", async (t) => {
89
let elev = new Eleventy();
@@ -424,3 +425,31 @@ test("#142: date 'git Last Modified' populates page.date", async (t) => {
424425
let comparisonDate = DateGitLastUpdated("./test/stubs-142/index.njk");
425426
t.is(result.content.trim(), "" + comparisonDate.getTime());
426427
});
428+
429+
test("Liquid shortcode with multiple arguments(issue #2348)", async (t) => {
430+
// NOTE issue #2348 was only active when you were processing multiple templates at the same time.
431+
432+
let elev = new Eleventy("./test/stubs-2367/", "./test/stubs-2367/_site", {
433+
config: function (eleventyConfig) {
434+
eleventyConfig.addShortcode("simplelink", function (...args) {
435+
return JSON.stringify(args);
436+
});
437+
},
438+
});
439+
440+
let arr = [
441+
"layout",
442+
"/mylayout",
443+
"layout",
444+
"/mylayout",
445+
"layout",
446+
"/mylayout",
447+
];
448+
let str = normalizeNewLines(`${JSON.stringify(arr)}
449+
${JSON.stringify(arr)}`);
450+
let results = await elev.toJSON();
451+
t.is(results.length, 2);
452+
let content = results.map((entry) => entry.content).sort();
453+
t.is(normalizeNewLines(content[0]), str);
454+
t.is(normalizeNewLines(content[1]), str);
455+
});

test/TemplateTest.js

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -293,45 +293,6 @@ test("One Layout (_layoutContent deprecated but supported)", async (t) => {
293293
t.is(data.keylayout, "valuelayout");
294294
});
295295

296-
test("Liquid shortcode with multiple arguments(issue #2348)", async (t) => {
297-
// NOTE issue #2348 was only active when you were processing multiple templates at the same time.
298-
299-
let eleventyConfig = new TemplateConfig();
300-
eleventyConfig.userConfig.addShortcode("simplelink", function (text, url) {
301-
return `<a href="${url}">${text} (${url})</a>`;
302-
});
303-
304-
let dataObj = new TemplateData("./test/stubs/", eleventyConfig);
305-
306-
let tmpl = getNewTemplate(
307-
"./test/stubs/templateWithLiquidShortcodeMultipleArguments.liquid",
308-
"./test/stubs/",
309-
"dist",
310-
dataObj,
311-
null,
312-
eleventyConfig
313-
);
314-
315-
t.is(
316-
(await tmpl.getFrontMatter()).data[tmpl.config.keys.layout],
317-
"layoutLiquid.liquid"
318-
);
319-
320-
let data = await tmpl.getData();
321-
t.is(data[tmpl.config.keys.layout], "layoutLiquid.liquid");
322-
323-
t.is(
324-
normalizeNewLines(cleanHtml(await tmpl.renderLayout(tmpl, data))),
325-
`<div id="layout">
326-
<p>Hello.</p>
327-
<a href="/somepage">world (/somepage)</a>
328-
</div>`
329-
);
330-
331-
t.is(data.keymain, "valuemain");
332-
t.is(data.keylayout, "valuelayout");
333-
});
334-
335296
test("One Layout (liquid test)", async (t) => {
336297
let eleventyConfig = new TemplateConfig();
337298
let dataObj = new TemplateData("./test/stubs/", eleventyConfig);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
text: layout
3+
url: "/mylayout"
4+
---
5+
{% simplelink text url text url text url %}
6+
{% simplelink text, url, text, url, text, url %}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
layout: layout.liquid
3+
---
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
layout: layout.liquid
3+
---

test/stubs/templateWithLiquidShortcodeMultipleArguments.liquid

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)