deno.land / x / lume@v2.1.4 / tests / liquid.test.ts

liquid.test.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { assertSiteSnapshot, build, getSite } from "./utils.ts";import liquid from "../plugins/liquid.ts";
Deno.test("build a site with liquid", async (t) => { const site = getSite({ src: "liquid", location: new URL("https://example.com/blog"), });
site.use(liquid());
// Register an async filter site.filter( "returnAsync", (text) => new Promise((resolve) => setTimeout(() => resolve(`${text} (async)`), 10) ), true, );
// Register custom tags site.helper( "upperCase", (text) => `<strong>${(text as string).toUpperCase()}</strong>`, { type: "tag" }, ); site.helper( "upperCaseBody", (text) => `<strong>${(text as string).toUpperCase()}</strong>`, { type: "tag", body: true }, ); site.helper( "upperCaseAsync", (text) => Promise.resolve(`<strong>${(text as string).toUpperCase()}</strong>`), { type: "tag", async: true }, ); site.helper( "upperCaseBodyAsync", (text) => Promise.resolve(`<strong>${(text as string).toUpperCase()}</strong>`), { type: "tag", body: true, async: true }, );
site.filter("fromPage", function (key) { return this?.data[key]; }); site.filter("fromPageAsync", function (key) { return Promise.resolve(this?.data[key]); }, true); site.helper( "fromPageTagAsync", function (key) { return Promise.resolve(`<strong>${this?.data[key]}</strong>`); }, { type: "tag", body: true, async: true }, );
await build(site); await assertSiteSnapshot(t, site);});
lume

Version Info

Tagged at
7 months ago