diff options
| author | herkulessi <git@herkulessi.de> | 2025-12-29 18:31:03 +0100 |
|---|---|---|
| committer | herkulessi <git@herkulessi.de> | 2025-12-29 18:31:03 +0100 |
| commit | ad08a1011dd7463e8a8d7adfade4fb69452f29e8 (patch) | |
| tree | 832d3997bc0e98ecc1a28f844b8b7368760cb26b /templates.go | |
| parent | 32e7fe5f94eee7e08f048d1ead1e7e82f29c46d6 (diff) | |
Diffstat (limited to 'templates.go')
| -rw-r--r-- | templates.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/templates.go b/templates.go index 00c1b31..408085c 100644 --- a/templates.go +++ b/templates.go @@ -7,6 +7,7 @@ import ( "html/template" "io/fs" "net/http" + texttemplate "text/template" ) type templates struct { @@ -68,3 +69,14 @@ func (w *Webpage) RenderTemplateToString(name string, data any) string { } return buf.String() } +func (w *Webpage) RenderTemplateToStringUnescaped(name string, data any) string { + buf := bytes.NewBuffer(nil) + tmpl, err := fs.ReadFile(w.getTemplateRoot(), "templates/"+name+".tmpl") + if err != nil { + panic(err) + } + if err := texttemplate.Must(texttemplate.New("templates/"+name+".tmpl").Funcs(w.templates.bindings).Parse(string(tmpl))).Execute(buf, data); err != nil { + panic(err) + } + return buf.String() +} |
