From 867ff4d28be2008adeab55cf2f155d7925132528 Mon Sep 17 00:00:00 2001 From: Feuerfuchs Date: Wed, 5 Jun 2019 17:29:31 +0200 Subject: Improved template readability --- template.go | 71 +++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 28 deletions(-) (limited to 'template.go') diff --git a/template.go b/template.go index 81730a6..242d0a2 100644 --- a/template.go +++ b/template.go @@ -2,32 +2,47 @@ package gopherproxy var tpltext = ` - - - -{{.Title}} - - - - -
-
-{{if .Lines}}{{range .Lines}} {{if .Link}} {{.Type}}  {{.Text}}{{else}}      {{.Text}}{{end}}
-{{end}}{{else}}{{.RawText}}{{end}}
-
- - + + + + {{ .Title }} + + + + +
+
+        {{- if .Lines -}}
+          {{- $content := "" -}}
+          {{- range .Lines -}}
+            {{- if ne $content "" -}}
+              {{- $content = printf "%s\n" $content -}}
+            {{- end -}}
+            {{- if .Link -}}
+              {{- $content = printf "%s%s" $content (printf "%s  %s" .Type .Type .Link .Text) -}}
+            {{- else -}}
+              {{- $content = printf "%s%s" $content (printf "     %s" .Text) -}}
+            {{- end -}}
+          {{- end -}}
+          {{- $content | safeHtml -}}
+        {{- else -}}
+          {{- .RawText -}}
+        {{- end -}}
+      
+
+ + ` -- cgit v1.2.3-54-g00ecf