Change motion content formatting

Use a linebreak sensitive paragraph instead of <pre> for motion content
output.
debian
Jan Dittberner 7 years ago
parent c48bd9e356
commit 14ed5a5020

@ -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)
}

@ -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>

Loading…
Cancel
Save