19 lines
672 B
JavaScript
19 lines
672 B
JavaScript
import { readFile } from "node:fs/promises";
|
|
import { lex } from "./views/engine/lexer.ts";
|
|
import { parse } from "./views/engine/parser.ts";
|
|
import { compileTemplate } from "./views/engine/compiler.ts";
|
|
const src = await readFile(
|
|
"./critdotrip/muddle/modules/app/views/index.spug",
|
|
"utf8",
|
|
);
|
|
const parsed = parse(lex(src));
|
|
const { source } = compileTemplate(parsed.nodes, {
|
|
path: "/x/i.spug",
|
|
dir: "/x",
|
|
frontmatter: parsed.frontmatter || "",
|
|
});
|
|
const a = source.indexOf("with (__ctx) {");
|
|
const b = source.indexOf('return __out.join(""");', a);
|
|
console.log("TEMPLATE BODY START", a);
|
|
console.log(source.slice(a, b).slice(0, 400));
|
|
console.log("...LEN", b - a);
|