From 31acd82fd86eed8cda5642204ae34f03d0fa8d43 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Thu, 14 Nov 2024 08:49:09 -0800 Subject: [PATCH] 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. --- .../partials/resource_builders/build_js.html | 3 +- .../partials/resource_builders/script.html | 29 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/layouts/partials/resource_builders/build_js.html b/layouts/partials/resource_builders/build_js.html index e859d6e..c756591 100644 --- a/layouts/partials/resource_builders/build_js.html +++ b/layouts/partials/resource_builders/build_js.html @@ -1,6 +1,7 @@ {{- $resourcePath := .resource -}} {{- $minify := .minify | default true -}} {{- $resource := dict -}} + {{- with resources.Get $resourcePath }} {{- if eq hugo.Environment "development" }} {{- with . | js.Build }} @@ -12,7 +13,7 @@ {{ $resource = . }} {{- end }} {{- end }} -{{ else }} +{{- else }} {{ warnf "Unable to find JavaScript resource: %s" $resourcePath }} {{- end }} diff --git a/layouts/partials/resource_builders/script.html b/layouts/partials/resource_builders/script.html index 83efe81..51e5ba8 100644 --- a/layouts/partials/resource_builders/script.html +++ b/layouts/partials/resource_builders/script.html @@ -19,23 +19,22 @@ looked up and built. {{- $shouldMinify := .minify -}} {{- $isModule := .module | default false -}} -{{ if eq (printf "%T" $resource) "string" }} +{{- if eq (printf "%T" $resource) "string" }} {{ $resource = partial "resource_builders/build_js.html" (dict "resource" $resource "minify" $shouldMinify) }} -{{ end }} +{{- end -}} -{{ with $resource }} - {{ if eq hugo.Environment "development" }} - - {{ else }} - - {{ end }} -{{ end }} +{{- with $resource }} + {{- if eq hugo.Environment "development" }} + + {{- else }} + + {{- end }} +{{- end -}}