mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-06-13 05:55:26 +00:00
update
This commit is contained in:
80
node_modules/@11ty/eleventy/test/TemplateRenderMustacheTest.js
generated
vendored
Normal file
80
node_modules/@11ty/eleventy/test/TemplateRenderMustacheTest.js
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
import test from "ava";
|
||||
import TemplateRender from "../src/TemplateRender";
|
||||
|
||||
// Mustache
|
||||
test("Mustache", async t => {
|
||||
t.is(new TemplateRender("mustache").getEngineName(), "mustache");
|
||||
});
|
||||
|
||||
test("Mustache Render", async t => {
|
||||
let fn = await new TemplateRender("mustache").getCompiledTemplate(
|
||||
"<p>{{name}}</p>"
|
||||
);
|
||||
t.is(await fn({ name: "Zach" }), "<p>Zach</p>");
|
||||
});
|
||||
|
||||
test("Mustache Render Partial (raw text content)", async t => {
|
||||
let fn = await new TemplateRender(
|
||||
"mustache",
|
||||
"./test/stubs/"
|
||||
).getCompiledTemplate("<p>{{> included}}</p>");
|
||||
t.is(await fn(), "<p>This is an include.</p>");
|
||||
});
|
||||
|
||||
test.skip("Mustache Render Partial (relative path, raw text content)", async t => {
|
||||
let fn = await new TemplateRender(
|
||||
"./test/stubs/does_not_exist_and_thats_ok.mustache",
|
||||
"./test/stubs/"
|
||||
).getCompiledTemplate("<p>{{> ./includedrelative}}</p>");
|
||||
t.is(await fn(), "<p>This is an includdde.</p>");
|
||||
});
|
||||
|
||||
test("Mustache Render Partial (uses a variable in content)", async t => {
|
||||
let fn = await new TemplateRender(
|
||||
"mustache",
|
||||
"./test/stubs/"
|
||||
).getCompiledTemplate("<p>{{> includedvar}}</p>");
|
||||
t.is(await fn({ name: "Zach" }), "<p>This is a Zach.</p>");
|
||||
});
|
||||
|
||||
test("Mustache Render Partial (Subdirectory)", async t => {
|
||||
let fn = await new TemplateRender(
|
||||
"mustache",
|
||||
"./test/stubs/"
|
||||
).getCompiledTemplate("<p>{{> subfolder/included}}</p>");
|
||||
t.is(await fn({ name: "Zach" }), "<p>This is an include.</p>");
|
||||
});
|
||||
|
||||
test("Mustache Render: with Library Override", async t => {
|
||||
let tr = new TemplateRender("mustache");
|
||||
|
||||
let lib = require("mustache");
|
||||
tr.engine.setLibrary(lib);
|
||||
|
||||
let fn = await tr.getCompiledTemplate("<p>{{name}}</p>");
|
||||
t.is(await fn({ name: "Zach" }), "<p>Zach</p>");
|
||||
});
|
||||
|
||||
test("Mustache Render Unescaped Output (no HTML)", async t => {
|
||||
let fn = await new TemplateRender("mustache").getCompiledTemplate(
|
||||
"<p>{{{name}}}</p>"
|
||||
);
|
||||
t.is(await fn({ name: "Zach" }), "<p>Zach</p>");
|
||||
});
|
||||
|
||||
test("Mustache Render Escaped Output", async t => {
|
||||
let fn = await new TemplateRender("mustache").getCompiledTemplate(
|
||||
"<p>{{name}}</p>"
|
||||
);
|
||||
t.is(
|
||||
await fn({ name: "<b>Zach</b>" }),
|
||||
"<p><b>Zach</b></p>"
|
||||
);
|
||||
});
|
||||
|
||||
test("Mustache Render Unescaped Output (HTML)", async t => {
|
||||
let fn = await new TemplateRender("mustache").getCompiledTemplate(
|
||||
"<p>{{{name}}}</p>"
|
||||
);
|
||||
t.is(await fn({ name: "<b>Zach</b>" }), "<p><b>Zach</b></p>");
|
||||
});
|
Reference in New Issue
Block a user