From ff8effaf3a37a67f85fdcc7bbb0e8873807f6881 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 14 Oct 2026 13:19:08 +0000 Subject: [PATCH] Fix a build break I shipped in the last commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `{{ partial "t.html" (dict "key" "by" "lang" .Site.Language.Lang) }}` inside `{{ with .Params.author }}`, where the dot is the author *string*. `.Site` on a string is an execution error, so the build fails — and with --panicOnWarning in the pipeline, the whole publish fails with it. Same again for `faq`, where the dot is a slice. It would have gone red on your first deploy: Salvador's post carries an author. My build check passed because every post in the fixture had neither an author nor a faq, so the two broken branches were never rendered. That is the actual mistake — not the dot, which is an easy slip, but checking a change to an optional branch with content that never takes it. The fixture now carries a post with author, author_url, faq, event, image, ai_generated and pinned all set at once. The rule is now "always `$.`" rather than "think about where you are": `$` is the page in every context, a bare `.` is only the page at top level, and the difference is invisible until a post happens to have the field. All sixteen call sites converted, and a test holds every one of them to it — proved by putting the bug back and watching it fail. Also the doc comment in t.html, which still claimed eleven keys. My replacement for it last commit silently matched nothing: I asserted on every other replacement in that script and not on this one. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn --- apps/board/tests/test_strings.py | 24 +++++++++++++++++++ themes/vienalatina/layouts/_default/list.html | 4 ++-- .../vienalatina/layouts/_default/single.html | 10 ++++---- themes/vienalatina/layouts/index.html | 4 ++-- .../vienalatina/layouts/partials/header.html | 6 ++--- themes/vienalatina/layouts/partials/t.html | 23 ++++++++++++++---- 6 files changed, 55 insertions(+), 16 deletions(-) diff --git a/apps/board/tests/test_strings.py b/apps/board/tests/test_strings.py index 9bfb6c9..038d597 100644 --- a/apps/board/tests/test_strings.py +++ b/apps/board/tests/test_strings.py @@ -58,6 +58,30 @@ def test_every_key_in_the_catalogue_is_used(): assert not orphans, f"defined but never shown: {orphans}" +def test_every_theme_call_site_passes_the_page_explicitly(): + """`$.Site.Language.Lang`, never `.Site.Language.Lang`. + + Inside a `{{ with }}` the dot is whatever that block holds — `.Params.author` + is a string, `.Params.faq` is a slice — and `.Site` on a string is an + execution error, not a wrong word. Two call sites shipped exactly that way, + and the build only went red on a post that happened to carry an `author`: + every post in the test fixture had neither, so a clean build proved nothing. + + `$` is the page in every context, so the rule is "always `$.`" rather than + "think about where you are", and this is what holds it. + """ + offenders = [] + for path in THEME.rglob("*"): + if not path.is_file() or path.suffix in (".css", ".js", ".toml"): + continue + for line_no, line in enumerate(path.read_text(encoding="utf-8").splitlines(), 1): + if 't.html"' in line and re.search(r'"lang"\s+\.', line): + offenders.append(f"{path.relative_to(THEME)}:{line_no}") + assert not offenders, ( + "these pass `.Site…` to t.html instead of `$.Site…`, which fails the " + f"build inside a `with`: {offenders}") + + def test_the_theme_and_the_catalogue_agree_on_the_public_defaults(): """Two copies, deliberately — Hugo reads the repository and the members area reads its own image, and neither can read the other's file. The same trade diff --git a/themes/vienalatina/layouts/_default/list.html b/themes/vienalatina/layouts/_default/list.html index d68ff95..6724b06 100644 --- a/themes/vienalatina/layouts/_default/list.html +++ b/themes/vienalatina/layouts/_default/list.html @@ -7,8 +7,8 @@
- {{ if .Params.ai_generated }}{{ partial "t.html" (dict "key" "ai" "lang" .Site.Language.Lang) }}{{ end }} - {{ if .Params.pinned }}{{ partial "t.html" (dict "key" "pinned" "lang" .Site.Language.Lang) }}{{ end }} + {{ if .Params.ai_generated }}{{ partial "t.html" (dict "key" "ai" "lang" $.Site.Language.Lang) }}{{ end }} + {{ if .Params.pinned }}{{ partial "t.html" (dict "key" "pinned" "lang" $.Site.Language.Lang) }}{{ end }}

{{ .Title }}

{{ .Description | default (.Summary | plainify | truncate 200) }}

diff --git a/themes/vienalatina/layouts/_default/single.html b/themes/vienalatina/layouts/_default/single.html index 551b0f3..673b809 100644 --- a/themes/vienalatina/layouts/_default/single.html +++ b/themes/vienalatina/layouts/_default/single.html @@ -19,7 +19,7 @@ nothing. */}} {{ with .Params.author }} - {{ partial "t.html" (dict "key" "by" "lang" .Site.Language.Lang) }} + {{ partial "t.html" (dict "key" "by" "lang" $.Site.Language.Lang) }} {{ with $.Params.author_url }} {{ $.Params.author }} {{ else }} @@ -33,11 +33,11 @@ into the German and Portuguese siblings by itself, which is right: a translated post was still machine-written. */}} {{ if .Params.ai_generated }} - {{ partial "t.html" (dict "key" "ai" "lang" .Site.Language.Lang) }} + {{ partial "t.html" (dict "key" "ai" "lang" $.Site.Language.Lang) }} {{ end }} {{/* And whether somebody put it at the top on purpose, so a reader arriving from the home page knows why it was first. */}} - {{ if .Params.pinned }}{{ partial "t.html" (dict "key" "pinned" "lang" .Site.Language.Lang) }}{{ end }} + {{ if .Params.pinned }}{{ partial "t.html" (dict "key" "pinned" "lang" $.Site.Language.Lang) }}{{ end }} @@ -96,7 +96,7 @@ cannot see is exactly what search engines penalise. */}} {{ with .Params.faq }}
-

{{ partial "t.html" (dict "key" "faq" "lang" .Site.Language.Lang) }}

+

{{ partial "t.html" (dict "key" "faq" "lang" $.Site.Language.Lang) }}

{{ range . }} {{ $parts := split . "|" }} @@ -112,7 +112,7 @@ {{ partial "share.html" . }} - {{ partial "t.html" (dict "key" "back" "lang" .Site.Language.Lang) }} + {{ partial "t.html" (dict "key" "back" "lang" $.Site.Language.Lang) }} {{/* Only on this template: the home page and the lists carry no share diff --git a/themes/vienalatina/layouts/index.html b/themes/vienalatina/layouts/index.html index 2476fd5..817f334 100644 --- a/themes/vienalatina/layouts/index.html +++ b/themes/vienalatina/layouts/index.html @@ -5,8 +5,8 @@
- {{ if .Params.ai_generated }}{{ partial "t.html" (dict "key" "ai" "lang" .Site.Language.Lang) }}{{ end }} - {{ if .Params.pinned }}{{ partial "t.html" (dict "key" "pinned" "lang" .Site.Language.Lang) }}{{ end }} + {{ if .Params.ai_generated }}{{ partial "t.html" (dict "key" "ai" "lang" $.Site.Language.Lang) }}{{ end }} + {{ if .Params.pinned }}{{ partial "t.html" (dict "key" "pinned" "lang" $.Site.Language.Lang) }}{{ end }}

{{ .Title }}

{{ .Description | default (.Summary | plainify | truncate 200) }}

diff --git a/themes/vienalatina/layouts/partials/header.html b/themes/vienalatina/layouts/partials/header.html index 3dfb0d7..3d74d0f 100644 --- a/themes/vienalatina/layouts/partials/header.html +++ b/themes/vienalatina/layouts/partials/header.html @@ -3,7 +3,7 @@ sans-serif, keeping the site free of third-party requests (GDPR). */}}
- + {{/* The logo uploaded in Gestión → Marca, and the site's name in letters when there is none. The alt text is the name either way, so a reader who does not see the picture reads the same thing. @@ -36,7 +36,7 @@ who has an account needs to find the door at a glance, and somebody who does not should see that there is one. In the bar at every width, so a phone never has to open a menu to find it. */}} - {{ partial "t.html" (dict "key" "community" "lang" .Site.Language.Lang) }} + {{ partial "t.html" (dict "key" "community" "lang" $.Site.Language.Lang) }} {{/* The ☰ itself. A