Different results for "if in .Params.tags" test

Following up from a few days later . . .

Since I could never get past the error I reported before, I ended up trying something else, which worked, but in a pretty ugly fashion (hugo_site/css.html at main · brycewray/hugo_site · GitHub) — so I’m now trying to pare it down to considerably DRY-er form and, agggh, am running into a similar problem.

Variables returned from a range show up as they should in tests (e.g., links with bogus attributes showing the variables), but I can’t get resources.ToCSS to accept the file if I supply its path via a variable rather than providing it as a string.

This works:

    {{ with $cssBuild -}}
      {{- $scss = resources.Get "scss/sectionals/home.scss" -}}
      {{- $css = $scss | resources.ToCSS $optionsCSS | fingerprint "md5" -}}
      <link rel="preload" as="style" href="{{ $css.RelPermalink }}">
      <link rel="stylesheet" href="{{ $css.RelPermalink }}" type="text/css">
    {{- end }}

But this doesn’t, even though the value of $cssBuild is scss/sectionals/home.scss:

    {{ with $cssBuild -}}
      {{- $scss = resources.Get $cssBuild }}
      {{- $css = $scss | resources.ToCSS $optionsCSS | fingerprint "md5" -}}
      <link rel="preload" as="style" href="{{ $css.RelPermalink }}">
      <link rel="stylesheet" href="{{ $css.RelPermalink }}" type="text/css">
    {{- end }}

With the latter, Hugo errors out with this message:

partials/css.html:81:34: executing "partials/css.html" at <resources.ToCSS>: error calling ToCSS: no Resource provided in transformation

I began to doubt my sanity at this point — especially after @jmooring couldn’t reproduce my earlier problem — so I even reverted to a couple of earlier Hugo versions (0.99.2, then 100.0) from 100.2, yet the result was the same in each case.

(Also: if it matters, I’m using macOS 12.4.)

I’ve put all this in a different repo branch, with the relevant partial at hugo_site/css.html at if-tags-3 · brycewray/hugo_site · GitHub. As before, I suspect this is something really stupid I’ve overlooked, but I just can’t see it after too many hours staring at it and seeing the inconsistent behavior over and over again. Thanks in advance to anyone who can show me what I’m doing wrong!