Template sets

This commit is contained in:
Zef Hemel
2023-11-15 14:56:34 +01:00
parent b26b7f4f0a
commit 663a15fe33
14 changed files with 121 additions and 16 deletions
+11 -8
View File
@@ -1,9 +1,10 @@
import { WidgetContent } from "$sb/app_event.ts";
import { handlebars, markdown, space, system, YAML } from "$sb/syscalls.ts";
import { markdown, space, system, YAML } from "$sb/syscalls.ts";
import { rewritePageRefs } from "$sb/lib/resolve.ts";
import { loadPageObject, replaceTemplateVars } from "../template/template.ts";
import { renderToText } from "$sb/lib/tree.ts";
import { PageMeta } from "$sb/types.ts";
import { renderTemplate } from "../template/plug_api.ts";
type TemplateConfig = {
// Pull the template from a page
@@ -39,13 +40,15 @@ export async function widget(
)
: undefined;
let rendered = config.raw ? templateText : await handlebars.renderTemplate(
templateText,
value,
{
page: pageMeta,
},
);
console.log("Value", value);
let { text: rendered } = config.raw
? { text: templateText }
: await renderTemplate(
templateText,
pageMeta,
value,
);
if (templatePage) {
const parsedMarkdown = await markdown.parseMarkdown(rendered);