Skip to content

Commit

Permalink
Cherry pick of 4c710d6
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed May 9, 2022
1 parent baca2ad commit 5cae435
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/TemplateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<a href="${url}">${text} (${url})</a>`;
});

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))),
`<div id="layout">
<p>Hello.</p>
<a href="/somepage">world (/somepage)</a>
</div>`
);

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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
layout: layoutLiquid.liquid
keymain: valuemain
title: 'Font Aliasing, or How to Rename a Font in CSS'
permalink: /rename-font2/
---

<p>Hello.</p>
{% simplelink "world", "/somepage" %}

0 comments on commit 5cae435

Please sign in to comment.