diff --git a/boardvoting.go b/boardvoting.go
index c93709c..3b62116 100644
--- a/boardvoting.go
+++ b/boardvoting.go
@@ -40,7 +40,11 @@ func getTemplateFilenames(templates []string) (result []string) {
}
func renderTemplate(w http.ResponseWriter, templates []string, context interface{}) {
- t := template.Must(template.New(templates[0]).Funcs(sprig.FuncMap()).ParseFiles(getTemplateFilenames(templates)...))
+ funcMaps := sprig.FuncMap()
+ funcMaps["nl2br"] = func(text string) template.HTML {
+ return template.HTML(strings.Replace(template.HTMLEscapeString(text), "\n", "
", -1))
+ }
+ t := template.Must(template.New(templates[0]).Funcs(funcMaps).ParseFiles(getTemplateFilenames(templates)...))
if err := t.Execute(w, context); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
diff --git a/templates/motion_fragments.html b/templates/motion_fragments.html
index ed036d7..dbe59c2 100644
--- a/templates/motion_fragments.html
+++ b/templates/motion_fragments.html
@@ -2,7 +2,7 @@
{{ .Status|toString|title }}
{{ .Modified|date "2006-01-02 15:04:05 UTC" }}
{{ wrap 76 .Content }}+
{{ wrap 76 .Content | nl2br }}