Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Commit a12c5c7

Browse files
fix: use Tree.Root.String() for JS/CSS extraction to avoid html/template escaping
RenderJS() and RenderCSS() were running static assets through html/template's Execute(), which HTML-escapes < to &lt; 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.
1 parent 35fb113 commit a12c5c7

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

internal/pssg/render/render.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,29 +245,23 @@ func (e *Engine) render(name string, data interface{}) (string, error) {
245245
}
246246

247247
// RenderCSS reads and returns the CSS template content.
248+
// Uses Tree.Root.String() to avoid html/template escaping in CSS code.
248249
func (e *Engine) RenderCSS() (string, error) {
249250
t := e.tmpl.Lookup("_styles.css")
250251
if t == nil {
251252
return "", nil
252253
}
253-
var buf bytes.Buffer
254-
if err := t.Execute(&buf, nil); err != nil {
255-
return "", err
256-
}
257-
return buf.String(), nil
254+
return t.Tree.Root.String(), nil
258255
}
259256

260257
// RenderJS reads and returns the JS template content.
258+
// Uses Tree.Root.String() to avoid html/template escaping < to &lt; in JS code.
261259
func (e *Engine) RenderJS() (string, error) {
262260
t := e.tmpl.Lookup("_main.js")
263261
if t == nil {
264262
return "", nil
265263
}
266-
var buf bytes.Buffer
267-
if err := t.Execute(&buf, nil); err != nil {
268-
return "", err
269-
}
270-
return buf.String(), nil
264+
return t.Tree.Root.String(), nil
271265
}
272266

273267
// GenerateCookModePrompt builds a cook-with-AI prompt for a recipe.

0 commit comments

Comments
 (0)