summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--templates.go12
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()
+}