Get the line breaking situation working correctly

The way whitespace is handled in Hugo templates is difficult to understand. I
accidentally pushed a broken version to production. This fixes the issue and
improves the formatting of the template code.
This commit is contained in:
Eryn Wells 2024-11-14 08:49:09 -08:00
parent 73e3cec711
commit 31acd82fd8
2 changed files with 16 additions and 16 deletions

View file

@ -1,6 +1,7 @@
{{- $resourcePath := .resource -}} {{- $resourcePath := .resource -}}
{{- $minify := .minify | default true -}} {{- $minify := .minify | default true -}}
{{- $resource := dict -}} {{- $resource := dict -}}
{{- with resources.Get $resourcePath }} {{- with resources.Get $resourcePath }}
{{- if eq hugo.Environment "development" }} {{- if eq hugo.Environment "development" }}
{{- with . | js.Build }} {{- with . | js.Build }}
@ -12,7 +13,7 @@
{{ $resource = . }} {{ $resource = . }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{ else }} {{- else }}
{{ warnf "Unable to find JavaScript resource: %s" $resourcePath }} {{ warnf "Unable to find JavaScript resource: %s" $resourcePath }}
{{- end }} {{- end }}

View file

@ -19,23 +19,22 @@ looked up and built.
{{- $shouldMinify := .minify -}} {{- $shouldMinify := .minify -}}
{{- $isModule := .module | default false -}} {{- $isModule := .module | default false -}}
{{ if eq (printf "%T" $resource) "string" }} {{- if eq (printf "%T" $resource) "string" }}
{{ {{
$resource = partial "resource_builders/build_js.html" $resource = partial "resource_builders/build_js.html"
(dict "resource" $resource "minify" $shouldMinify) (dict "resource" $resource "minify" $shouldMinify)
}} }}
{{ end }} {{- end -}}
{{ with $resource }} {{- with $resource }}
{{ if eq hugo.Environment "development" }} {{- if eq hugo.Environment "development" }}
<script {{ if $isModule }}type="module"{{ end }} src="{{ .RelPermalink }}"></script> <script src="{{ .RelPermalink }}"
{{ else }} {{- if $isModule }} type="module"{{ end -}}
<script ></script>
{{- if $isModule }} type="module" {{ end -}} {{- else }}
src="{{ .RelPermalink }}" <script src="{{ .RelPermalink }}" crossorigin="anonymous"
{{- with .Data.Integrity }} integrity="{{ . }}" {{ end -}} {{- if $isModule }} type="module"{{ end }}
crossorigin="anonymous" {{- with .Data.Integrity }} integrity="{{ . }}"{{ end -}}
{{- "" -}}> ></script>
</script> {{- end }}
{{ end }} {{- end -}}
{{ end }}