Change motion content formatting
Use a linebreak sensitive paragraph instead of <pre> for motion content output.
This commit is contained in:
parent
c48bd9e356
commit
14ed5a5020
2 changed files with 6 additions and 2 deletions
|
@ -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…
Reference in a new issue