diff --git a/.gitignore b/.gitignore index 5bcf213..8c55080 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,5 @@ /* -# editors -!/.vscode - # makefile !/makefile diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index ff30c44..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "editor.tabSize": 2 -} \ No newline at end of file diff --git a/ren/str.test.ts b/ren/str.test.ts index d44e9c9..2d0617e 100644 --- a/ren/str.test.ts +++ b/ren/str.test.ts @@ -1,5 +1,6 @@ import { assertEquals } from "testing/asserts.ts"; -import { E, F, TextNode } from "../core/node.ts"; +import { TextNode } from "../core/node.ts"; +import { E, F } from "./node.ts"; import { StrRenderer } from "./str.ts"; @@ -131,3 +132,15 @@ Deno.test({ assertEquals(res, "
"); }, }); + +Deno.test({ + name: "should wrap node", + fn: () => { + const layout = E("body", [], []); + + const ren = new StrRenderer({ wrapNode: (node) => E("html", [], [node]) }); + const res = ren.render(layout); + + assertEquals(res, ""); + }, +}); diff --git a/ren/str.ts b/ren/str.ts index accbd3f..7a56b10 100644 --- a/ren/str.ts +++ b/ren/str.ts @@ -14,27 +14,37 @@ import { Renderer } from "./types.ts"; interface StrRendererOpts { doctype?: string; forceRenderDoctype?: boolean; + wrapNode?: (node: AnyNode) => AnyNode; } export class StrRenderer implements Renderer