From 1e5e965572f36718e921992b13d15ff906ca137a Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Tue, 13 Aug 2024 01:53:36 +0200 Subject: [PATCH] Refactor some templating to avoid spurious whitespace --- .../layouts/_default/single.html | 35 +++++++++---------- themes/hugo-theme-ipng/layouts/home.html | 1 - .../layouts/partials/blog-taxonomy-info.html | 25 +++++++------ .../layouts/partials/footer.html | 15 ++++---- .../layouts/shortcodes/image.html | 22 ++++++------ 5 files changed, 47 insertions(+), 51 deletions(-) diff --git a/themes/hugo-theme-ipng/layouts/_default/single.html b/themes/hugo-theme-ipng/layouts/_default/single.html index d9e5f4b..ade9b7c 100644 --- a/themes/hugo-theme-ipng/layouts/_default/single.html +++ b/themes/hugo-theme-ipng/layouts/_default/single.html @@ -1,24 +1,23 @@ -{{ define "main" }} +{{- define "main" }}
- {{ if in site.Params.mainSections .Page.Section }} +{{- if in site.Params.mainSections .Page.Section }}

{{ .Title }}

- {{ else }} +{{- else }}

{{ .Title }}

- {{ end }} - - {{- /* Show post information if it's a post, otherwise just the content */ -}} - {{ if in site.Params.mainSections .Page.Section }} - - -
- {{ .Content }} -
- {{ template "_internal/disqus.html" . }} - {{ else }} - {{ .Content }} - {{ end }} +{{- end }} +{{- /* Show post information if it's a post, otherwise just the content */ -}} +{{- if in site.Params.mainSections .Page.Section }} + +
+{{ .Content }} +
+{{- template "_internal/disqus.html" . }} +{{- else }} +{{- .Content }} +{{- end }}
-{{ end }} +{{- end }} diff --git a/themes/hugo-theme-ipng/layouts/home.html b/themes/hugo-theme-ipng/layouts/home.html index 1644dae..f9f9986 100644 --- a/themes/hugo-theme-ipng/layouts/home.html +++ b/themes/hugo-theme-ipng/layouts/home.html @@ -38,5 +38,4 @@ {{ end }} - 
{{ end }} diff --git a/themes/hugo-theme-ipng/layouts/partials/blog-taxonomy-info.html b/themes/hugo-theme-ipng/layouts/partials/blog-taxonomy-info.html index c036ccd..b478fb3 100644 --- a/themes/hugo-theme-ipng/layouts/partials/blog-taxonomy-info.html +++ b/themes/hugo-theme-ipng/layouts/partials/blog-taxonomy-info.html @@ -1,17 +1,16 @@ -{{ with .Params.Categories }} +{{- with .Params.Categories }}   |   Categories: - {{ $sort := sort . }} - {{ $links := apply $sort "partial" "post-category-link" "." }} - {{ $clean := apply $links "chomp" "." }} - {{ delimit $clean ", " | safeHTML }} + {{- $sort := sort . }} + {{- $links := apply $sort "partial" "post-category-link" "." }} + {{- $clean := apply $links "chomp" "." }} + {{- delimit $clean ", " | safeHTML }} -{{ end }} - -{{ with .Params.Tags }} +{{- end }} +{{- with .Params.Tags }}   |   Tags: - {{ $sort := sort . }} - {{ $links := apply $sort "partial" "post-tag-link" "." }} - {{ $clean := apply $links "chomp" "." }} - {{ delimit $clean ", " | safeHTML }} + {{- $sort := sort . }} + {{- $links := apply $sort "partial" "post-tag-link" "." }} + {{- $clean := apply $links "chomp" "." }} + {{- delimit $clean ", " | safeHTML }} -{{ end }} +{{- end -}} diff --git a/themes/hugo-theme-ipng/layouts/partials/footer.html b/themes/hugo-theme-ipng/layouts/partials/footer.html index 17a08c4..13746a1 100644 --- a/themes/hugo-theme-ipng/layouts/partials/footer.html +++ b/themes/hugo-theme-ipng/layouts/partials/footer.html @@ -1,18 +1,19 @@ + diff --git a/themes/hugo-theme-ipng/layouts/shortcodes/image.html b/themes/hugo-theme-ipng/layouts/shortcodes/image.html index 06a9523..dd6759e 100644 --- a/themes/hugo-theme-ipng/layouts/shortcodes/image.html +++ b/themes/hugo-theme-ipng/layouts/shortcodes/image.html @@ -1,32 +1,30 @@
{{- if .Get "link" -}} {{- end }} {{ with .Get {{- if .Get "link" }}{{ end -}} - {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}} -
- {{ with (.Get "title") -}} -

{{ . }}

- {{- end -}} - {{- if or (.Get "caption") (.Get "attr") -}}

- {{- .Get "caption" | markdownify -}} + {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") }} +

+ {{ with (.Get "title") -}} +

{{ . }}

+ {{- end -}} + {{- if or (.Get "caption") (.Get "attr") -}}

+ {{- .Get "caption" | markdownify -}} {{- with .Get "attrlink" }} {{- end -}} {{- .Get "attr" | markdownify -}} {{- if .Get "attrlink" }}{{ end }}

{{- end }} -
+
{{- end }}