tpl: Run gotmplfmt -w .

This commit is contained in:
Bjørn Erik Pedersen
2026-05-18 13:41:31 +02:00
parent 6a2a03806d
commit d31a9275c6
29 changed files with 953 additions and 947 deletions
@@ -18,6 +18,5 @@
{{- if $v -}}
{{- printf " %s=%q" $k ($v | transform.HTMLEscape) | safeHTMLAttr -}}
{{- end -}}
{{- end -}}
>
{{- end -}}>
{{- /**/ -}}
@@ -11,8 +11,7 @@
<th
{{- with .Alignment }}
{{- printf " style=%q" (printf "text-align: %s" .) | safeHTMLAttr }}
{{- end -}}
>
{{- end -}}>
{{- .Text -}}
</th>
{{- end }}
@@ -26,8 +25,7 @@
<td
{{- with .Alignment }}
{{- printf " style=%q" (printf "text-align: %s" .) | safeHTMLAttr }}
{{- end -}}
>
{{- end -}}>
{{- .Text -}}
</td>
{{- end }}
@@ -9,7 +9,9 @@
{{- $imgs = $imgs | append (dict
"Image" .
"RelPermalink" .RelPermalink
"Permalink" .Permalink) }}
"Permalink" .Permalink
)
}}
{{- end }}
{{- end }}
{{/* Use the first one of site images as the fallback. */}}
@@ -28,19 +30,23 @@
{{- $imgs = $imgs | append (dict
"Image" .
"RelPermalink" .RelPermalink
"Permalink" .Permalink) }}
"Permalink" .Permalink
)
}}
{{- else }}
{{- $imgs = $imgs | append (dict
"RelPermalink" (relURL $img)
"Permalink" (absURL $img)
) }}
)
}}
{{- end }}
{{- else }}
{{/* External image */}}
{{- $imgs = $imgs | append (dict
"RelPermalink" $img
"Permalink" $img
) }}
)
}}
{{- end }}
{{- end }}
{{- return $imgs }}
@@ -1,6 +1,6 @@
{{- $pc := .Site.Config.Privacy.Disqus -}}
{{- if not $pc.Disable -}}
{{ if .Site.Config.Services.Disqus.Shortname }}<div id="disqus_thread"></div>
{{ if .Site.Config.Services.Disqus.Shortname }}<div id="disqus_thread"></div>
<script>
window.disqus_config = function () {
{{with .Params.disqus_identifier }}this.page.identifier = '{{ . }}';{{end}}
@@ -18,6 +18,7 @@
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>{{end}}
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
{{ end }}
{{- end -}}
@@ -30,7 +30,7 @@
{{/* Format: default
{{/* --------------------------------------------------------------------- */}}
{{- define "_partials/inline/pagination/default.html" }}
{{- with .Paginator }}
{{- with .Paginator }}
{{- $currentPageNumber := .PageNumber }}
{{- with .First }}
@@ -95,13 +95,13 @@
</li>
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}
{{/* Format: terse
{{/* --------------------------------------------------------------------- */}}
{{- define "_partials/inline/pagination/terse.html" }}
{{- with .Paginator }}
{{- with .Paginator }}
{{- $currentPageNumber := .PageNumber }}
{{- with .First }}
@@ -150,5 +150,5 @@
</li>
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}
@@ -63,7 +63,7 @@
<main>
{{ $codeStyle := "dracula" }}
<div class="error">
{{ highlight .Error "apl" (printf "linenos=false,noclasses=true,style=%s" $codeStyle ) }}
{{ highlight .Error "apl" (printf "linenos=false,noclasses=true,style=%s" $codeStyle) }}
</div>
<hr>
{{ range $i, $e := .Files }}
@@ -1,7 +1,7 @@
{{ define "__h_simple_css" }}{{/* These template definitions are global. */}}
{{- if not (.Page.Scratch.Get "__h_simple_css") -}}
{{/* Only include once */}}
{{- .Page.Scratch.Set "__h_simple_css" true -}}
{{/* Only include once */}}
{{- .Page.Scratch.Set "__h_simple_css" true -}}
<style>
.__h_video {
position: relative;
@@ -68,8 +68,7 @@ Renders an HTML details element.
{{- with $class }} class="{{ . }}" {{- end }}
{{- with $name }} name="{{ . }}" {{- end }}
{{- with $open }} open {{- end }}
{{- with $title }} title="{{ . }}" {{- end -}}
>
{{- with $title }} title="{{ . }}" {{- end -}}>
<summary>{{ $summary | .Page.RenderString }}</summary>
{{ .Inner | .Page.RenderString (dict "display" "block") -}}
</details>
@@ -13,12 +13,8 @@
<img src="{{ $src }}"
{{- if or (.Get "alt") (.Get "caption") }}
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
{{- end -}}
{{- with .Get "width" }} width="{{ . }}"{{ end -}}
{{- with .Get "height" }} height="{{ . }}"{{ end -}}
{{- with .Get "loading" }} loading="{{ . }}"{{ end -}}
><!-- Closing img tag -->
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify | plainify }}{{ end }}"
{{- end -}}{{- with .Get "width" }} width="{{ . }}"{{ end -}}{{- with .Get "height" }} height="{{ . }}"{{ end -}}{{- with .Get "loading" }} loading="{{ . }}"{{ end -}}><!-- Closing img tag -->
{{- if .Get "link" }}</a>{{ end -}}
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
<figcaption>
@@ -8,7 +8,7 @@
{{- end -}}
{{- define "render-instagram" -}}
<blockquote
<blockquote
class="instagram-media"
data-instgrm-captioned
data-instgrm-permalink="https://www.instagram.com/p/{{ .id }}"
@@ -26,7 +26,7 @@
width: -webkit-calc(100% - 2px);
width: calc(100% - 2px);
"
>
>
<div style="padding: 16px">
<a
href="https://www.instagram.com/p/{{ .id }}"
@@ -235,10 +235,11 @@
width: 144px;
"
></div></div
></a>
>
</a>
</div>
</blockquote>
{{- if not .pc.Simple -}}
</blockquote>
{{- if not .pc.Simple -}}
<script async src="https://www.instagram.com/embed.js"></script>
{{- end -}}
{{- end -}}
{{- end -}}
@@ -1,4 +1,5 @@
{{- $name := (.Get 0) -}}
{{- with $name -}}
{{- with ($.Page.Param .) }}{{ . }}{{ else }}{{ errorf "Param %q not found: %s" $name $.Position }}{{ end -}}
{{- else }}{{ errorf "Missing param key: %s" $.Position }}{{ end -}}
{{- with ($.Page.Param .) }}{{ . }}{{ else }}{{ errorf "Param %q not found: %s" $name $.Position }}{{ end -}}
{{- else }}{{ errorf "Missing param key: %s" $.Position }}
{{ end -}}
@@ -50,7 +50,7 @@ Encodes the given text into a QR code using the specified options and renders th
{{- $loading := or (.Get "loading") "" }}
{{- /* Validate arguments. */}}
{{- $errors := false}}
{{- $errors := false }}
{{- if not $text }}
{{- errorf "The %q shortcode requires a %q argument. See %s" .Name "text" .Position }}
{{- $errors = true }}
@@ -72,8 +72,6 @@ Encodes the given text into a QR code using the specified options and renders th
{{- with $alt }} alt="{{ $alt }}" {{- end }}
{{- with $class }} class="{{ $class }}" {{- end }}
{{- with $id }} id="{{ $id }}" {{- end }}
{{- with $title }} title="{{ $title }}" {{- end -}}
{{- with $loading }} loading="{{ $loading }}" {{- end -}}
>
{{- with $title }} title="{{ $title }}" {{- end -}}{{- with $loading }} loading="{{ $loading }}" {{- end -}}>
{{- end }}
{{- end -}}
@@ -19,11 +19,11 @@
{{- end -}}
{{- define "render-vimeo" -}}
{{- $dnt := cond site.Config.Privacy.Vimeo.EnableDNT 1 0 -}}
{{- $url := urls.JoinPath "https://vimeo.com" .id -}}
{{- $query := querify "url" $url "dnt" $dnt -}}
{{- $request := printf "https://vimeo.com/api/oembed.json?%s" $query -}}
{{- with try (resources.GetRemote $request) -}}
{{- $dnt := cond site.Config.Privacy.Vimeo.EnableDNT 1 0 -}}
{{- $url := urls.JoinPath "https://vimeo.com" .id -}}
{{- $query := querify "url" $url "dnt" $dnt -}}
{{- $request := printf "https://vimeo.com/api/oembed.json?%s" $query -}}
{{- with try (resources.GetRemote $request) -}}
{{- with .Err -}}
{{- warnidf "shortcode-vimeo-simple" "The %q shortcode was unable to retrieve the remote data: %s. See %s" $.ctx.Name . $.ctx.Position -}}
{{- else with .Value -}}
@@ -48,5 +48,5 @@
{{- else -}}
{{- warnidf "shortcode-vimeo-simple" "The %q shortcode was unable to retrieve the remote data. See %s" $.ctx.Name $.ctx.Position -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
@@ -14,10 +14,10 @@
{{- end -}}
{{- define "render-x" -}}
{{- $url := printf "https://x.com/%v/status/%v" .user .id -}}
{{- $query := querify "url" $url "dnt" .dnt -}}
{{- $request := printf "https://publish.x.com/oembed?%s" $query -}}
{{- with try (resources.GetRemote $request) -}}
{{- $url := printf "https://x.com/%v/status/%v" .user .id -}}
{{- $query := querify "url" $url "dnt" .dnt -}}
{{- $request := printf "https://publish.x.com/oembed?%s" $query -}}
{{- with try (resources.GetRemote $request) -}}
{{- with .Err -}}
{{- warnidf "shortcode-x-getremote" "The %q shortcode was unable to retrieve the remote data: %s. See %s" $.ctx.Name . $.ctx.Position -}}
{{- else with .Value -}}
@@ -25,5 +25,5 @@
{{- else -}}
{{- warnidf "shortcode-x-getremote" "The %q shortcode was unable to retrieve the remote data. See %s" $.ctx.Name $.ctx.Position -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
@@ -9,11 +9,11 @@
{{- end -}}
{{- define "render-simple-x" -}}
{{- $dnt := site.Config.Privacy.X.EnableDNT }}
{{- $url := printf "https://x.com/%v/status/%v" .user .id -}}
{{- $query := querify "url" $url "dnt" $dnt "omit_script" true -}}
{{- $request := printf "https://publish.x.com/oembed?%s" $query -}}
{{- with try (resources.GetRemote $request) -}}
{{- $dnt := site.Config.Privacy.X.EnableDNT }}
{{- $url := printf "https://x.com/%v/status/%v" .user .id -}}
{{- $query := querify "url" $url "dnt" $dnt "omit_script" true -}}
{{- $request := printf "https://publish.x.com/oembed?%s" $query -}}
{{- with try (resources.GetRemote $request) -}}
{{- with .Err -}}
{{- warnidf "shortcode-x-simple-getremote" "The %q shortcode was unable to retrieve the remote data: %s. See %s" $.ctx.Name . $.ctx.Position -}}
{{- else with .Value -}}
@@ -24,11 +24,11 @@
{{- else -}}
{{- warnidf "shortcode-x-simple-getremote" "The %q shortcode was unable to retrieve the remote data. See %s" $.ctx.Name $.ctx.Position -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- define "__h_simple_x_css" -}}
{{- if not (.ctx.Page.Store.Get "__h_simple_x_css") -}}
{{- if not (.ctx.Page.Store.Get "__h_simple_x_css") -}}
{{/* Only include once */}}
{{- .ctx.Page.Store.Set "__h_simple_x_css" true -}}
<style type="text/css">
@@ -56,5 +56,5 @@
text-decoration: underline;
}
</style>
{{- end -}}
{{- end -}}
{{- end -}}
@@ -110,16 +110,14 @@ Renders an embedded YouTube video.
{{- /* Render. */ -}}
<div
{{- with $class }} class="{{ . }}" {{- end }}
{{- with $divStyle }} style="{{ . | safeCSS }}" {{- end -}}
>
{{- with $divStyle }} style="{{ . | safeCSS }}" {{- end -}}>
<iframe
{{- with $iframeAllowList }} allow="{{ . }}" {{- end }}
{{- with $loading }} loading="{{ . }}" {{- end }}
{{- with $referrerpolicy }} referrerpolicy="{{ . }}" {{- end }}
{{- with $src }} src="{{ . }}" {{- end }}
{{- with $iframeStyle}} style="{{ . | safeCSS }}" {{- end }}
{{- with $title }} title="{{ . }}" {{- end -}}
></iframe>
{{- with $iframeStyle }} style="{{ . | safeCSS }}" {{- end }}
{{- with $title }} title="{{ . }}" {{- end -}}></iframe>
</div>
{{- else }}
{{- errorf "The %q shortcode requires an id argument. See %s" .Name .Position }}
+16 -8
View File
@@ -22,13 +22,13 @@
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
{{- $pages := slice }}
{{- if or $.IsHome $.IsSection }}
{{- $pages = $pctx.RegularPages }}
{{- $pages = $pctx.RegularPages }}
{{- else }}
{{- $pages = $pctx.Pages }}
{{- $pages = $pctx.Pages }}
{{- end }}
{{- $limit := .Site.Config.Services.RSS.Limit }}
{{- if ge $limit 1 }}
{{- $pages = $pages | first $limit }}
{{- $pages = $pages | first $limit }}
{{- end }}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
@@ -37,11 +37,19 @@
<link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<generator>Hugo</generator>
<language>{{ site.Language.Locale }}</language>{{ with $authorEmail }}
<managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
<copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }}
<lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
<language>{{ site.Language.Locale }}</language>
{{ with $authorEmail }}
<managingEditor>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>
{{ end }}
{{ with $authorEmail }}
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>
{{ end }}
{{ with .Site.Copyright }}
<copyright>{{ . }}</copyright>
{{ end }}
{{ if not .Date.IsZero }}
<lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>
{{ end }}
{{- with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end }}
@@ -1,3 +1,4 @@
{{/* gotmplfmt-ignore-all */}}
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
+11 -11
View File
@@ -122,7 +122,7 @@ Content: {{ .Content }}
`
b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", "35b077dcb9887a84")
b.AssertFileContent("public/index.html", "c18e12c59a2f9bdb")
}
func TestHighlightShortcode(t *testing.T) {
@@ -237,12 +237,12 @@ Content: {{ .Content }}
// Regular mode
b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", "6e93404b93277876")
b.AssertFileContent("public/index.html", "336bb64b13c24575")
// Simple mode
files = strings.ReplaceAll(files, "privacy.instagram.simple = false", "privacy.instagram.simple = true")
b = hugolib.Test(t, files)
b.AssertFileContent("public/index.html", "2c1dce3881be0513")
b.AssertFileContent("public/index.html", "4c094707f37b2340")
}
func TestParamShortcode(t *testing.T) {
@@ -469,14 +469,14 @@ Content: {{ .Content }}
// Regular mode
b := hugolib.Test(t, files)
b.AssertFileContent("public/p1/index.html", "31c54d7f8c54f73d")
b.AssertFileContent("public/p2/index.html", "31c54d7f8c54f73d")
b.AssertFileContent("public/p3/index.html", "7c073565f380599b")
b.AssertFileContent("public/p1/index.html", "2144844b57ee39d8")
b.AssertFileContent("public/p2/index.html", "2144844b57ee39d8")
b.AssertFileContent("public/p3/index.html", "a131e93ce53bc318")
// Simple mode
files = strings.ReplaceAll(files, "privacy.vimeo.simple = false", "privacy.vimeo.simple = true")
b = hugolib.Test(t, files)
b.AssertFileContent("public/p1/index.html", "fb22905d5b100a5a")
b.AssertFileContent("public/p1/index.html", "582bde2225dc43c0")
// Simple mode with non-existent id
files = strings.ReplaceAll(files, "{{< vimeo 19899678 >}}", "{{< vimeo __id_does_not_exist__ >}}")
@@ -587,14 +587,14 @@ title: p2
b := hugolib.Test(t, files)
b.AssertFileContent("public/p1/index.html", "4b54bf9bd03946ec")
b.AssertFileContent("public/p2/index.html", "289c655e727e596c")
b.AssertFileContent("public/p1/index.html", "365fe481b0377cd9")
b.AssertFileContent("public/p2/index.html", "82d7f05fb1fefb3b")
files = strings.ReplaceAll(files, "privacy.youtube.privacyEnhanced = false", "privacy.youtube.privacyEnhanced = true")
b = hugolib.Test(t, files)
b.AssertFileContent("public/p1/index.html", "78eb19b5c6f3768f")
b.AssertFileContent("public/p2/index.html", "a6db910a9cf54bc1")
b.AssertFileContent("public/p1/index.html", "48398992f5ff0afc")
b.AssertFileContent("public/p2/index.html", "116436ffc3f62191")
}
func TestShortcodePlainTextVsHTMLTemplateIssue13698(t *testing.T) {