From a12c5c791f6960831dbb7489e6b25ccb01879c56 Mon Sep 17 00:00:00 2001 From: jonathanpopham Date: Fri, 27 Feb 2026 22:26:52 -0500 Subject: [PATCH] fix: use Tree.Root.String() for JS/CSS extraction to avoid html/template escaping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RenderJS() and RenderCSS() were running static assets through html/template's Execute(), which HTML-escapes < to < in the output. This broke all for-loops and comparisons in main.js (8 instances), causing a syntax error that prevented all D3 graphs from rendering. Same root cause as the template.HTML → template.JS fix: the text/template → html/template migration in 8f1470b. --- internal/pssg/render/render.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/internal/pssg/render/render.go b/internal/pssg/render/render.go index 912d2db..dbb92f6 100644 --- a/internal/pssg/render/render.go +++ b/internal/pssg/render/render.go @@ -245,29 +245,23 @@ func (e *Engine) render(name string, data interface{}) (string, error) { } // RenderCSS reads and returns the CSS template content. +// Uses Tree.Root.String() to avoid html/template escaping in CSS code. func (e *Engine) RenderCSS() (string, error) { t := e.tmpl.Lookup("_styles.css") if t == nil { return "", nil } - var buf bytes.Buffer - if err := t.Execute(&buf, nil); err != nil { - return "", err - } - return buf.String(), nil + return t.Tree.Root.String(), nil } // RenderJS reads and returns the JS template content. +// Uses Tree.Root.String() to avoid html/template escaping < to < in JS code. func (e *Engine) RenderJS() (string, error) { t := e.tmpl.Lookup("_main.js") if t == nil { return "", nil } - var buf bytes.Buffer - if err := t.Execute(&buf, nil); err != nil { - return "", err - } - return buf.String(), nil + return t.Tree.Root.String(), nil } // GenerateCookModePrompt builds a cook-with-AI prompt for a recipe.