Fix custom CSS

This commit is contained in:
r 2022-05-10 17:25:58 +00:00
parent 471701f029
commit 4ad71587d8
2 changed files with 6 additions and 1 deletions

View File

@ -129,6 +129,10 @@ func raw(s string) template.HTML {
return template.HTML(s) return template.HTML(s)
} }
func rawCSS(s string) template.CSS {
return template.CSS(s)
}
type Renderer interface { type Renderer interface {
Render(ctx *Context, writer io.Writer, page string, data interface{}) (err error) Render(ctx *Context, writer io.Writer, page string, data interface{}) (err error)
} }
@ -150,6 +154,7 @@ func NewRenderer(templateGlobPattern string) (r *renderer, err error) {
"WithContext": withContext, "WithContext": withContext,
"HTML": template.HTMLEscapeString, "HTML": template.HTMLEscapeString,
"Raw": raw, "Raw": raw,
"RawCSS": rawCSS,
}).ParseGlob(templateGlobPattern) }).ParseGlob(templateGlobPattern)
if err != nil { if err != nil {
return return

View File

@ -26,7 +26,7 @@
<script src="/static/fluoride.js"></script> <script src="/static/fluoride.js"></script>
{{end}} {{end}}
{{if $.Ctx.UserCSS}} {{if $.Ctx.UserCSS}}
<style>{{$.Ctx.UserCSS}}</style> <style>{{RawCSS $.Ctx.UserCSS}}</style>
{{end}} {{end}}
</head> </head>
<body {{if $.Ctx.DarkMode}}class="dark"{{end}}> <body {{if $.Ctx.DarkMode}}class="dark"{{end}}>