summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Dittberner <jandd@cacert.org>2017-05-14 15:01:12 +0200
committerJan Dittberner <jandd@cacert.org>2017-05-14 15:01:12 +0200
commit14ed5a502038ae8a6833c412c94b4fbfe06648a3 (patch)
tree6aa0078ebe274663dafe1a1edd4458400b6b8f5b
parentc48bd9e356f16fcf8c14f7c6e34aec2469fe51bb (diff)
downloadcacert-boardvoting-14ed5a502038ae8a6833c412c94b4fbfe06648a3.tar.gz
cacert-boardvoting-14ed5a502038ae8a6833c412c94b4fbfe06648a3.tar.xz
cacert-boardvoting-14ed5a502038ae8a6833c412c94b4fbfe06648a3.zip
Change motion content formatting
Use a linebreak sensitive paragraph instead of <pre> for motion content output.
-rw-r--r--boardvoting.go6
-rw-r--r--templates/motion_fragments.html2
2 files changed, 6 insertions, 2 deletions
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", "<br>", -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 @@
<span class="ui {{ template "status_class" .Status }} ribbon label">{{ .Status|toString|title }}</span>
<span class="header">{{ .Modified|date "2006-01-02 15:04:05 UTC" }}</span>
<h3 class="header"><a href="/motions/{{ .Tag }}">{{ .Tag }}: {{ .Title }}</a></h3>
-<pre>{{ wrap 76 .Content }}</pre>
+<p>{{ wrap 76 .Content | nl2br }}</p>
<table class="ui small definition table">
<tbody>
<tr>