feat: Added tools feature for CSS pre/post processors.

This commit is contained in:
Spencer Brower
2026-09-08 13:21:58 -04:00
parent 2f997e89bb
commit 122627c51c
8 changed files with 535 additions and 12 deletions
+20 -4
View File
@@ -139,8 +139,14 @@ render_template :: proc(
ctx: Template_Context,
partials: map[string]mustache.Template,
reported_errors: ^map[string]bool,
tools: ^mustache.Tool_Registry,
) -> string {
result, err := mustache.render(content_tpl, []any{ctx.site, ctx.page, ctx}, partials)
result, err := mustache.render(
content_tpl,
[]any{ctx.site, ctx.page, ctx},
partials,
tools = tools,
)
if err != nil {
formatted := mustache.format_render_error(
err,
@@ -185,6 +191,16 @@ render_site :: proc(site: ^Site) {
timezone = site.tz,
}
// Prepare the `tool` pipe registry for this build (commands were filled from
// thor.json at config time). A pointer to it is threaded into every
// mustache.render call.
mustache.tool_registry_init(
&site.tool_registry,
site.assets_dir,
site.output_dir,
.Minify in site.features,
)
// Find home page
home: Page
has_home := false
@@ -317,7 +333,7 @@ render_page_html :: proc(
ctx.page = page
ctx.og = og_for_page(site.og, page)
ctx.params = merge_params(site.params, page.params)
return render_template(content_tpl, ctx, partials, seen)
return render_template(content_tpl, ctx, partials, seen, &site.tool_registry)
}
render_home_html :: proc(
@@ -341,7 +357,7 @@ render_home_html :: proc(
ctx.og = og_for_page(site.og, home)
ctx.params = merge_params(site.params, home.params)
return render_template(content_tpl, ctx, partials, seen)
return render_template(content_tpl, ctx, partials, seen, &site.tool_registry)
}
render_section :: proc(
@@ -380,7 +396,7 @@ render_section :: proc(
}
ctx.posts = posts
ctx.params = merge_params(site.params, ctx.page.params)
return render_template(content_tpl, ctx, partials, seen)
return render_template(content_tpl, ctx, partials, seen, &site.tool_registry)
}
load_partials :: proc(vfs: ^VFS) -> map[string]mustache.Template {