Warnings emitted within template scopes are muted?

I was extending a shortcode template and noticed that warnings about missing files (which I like) disappeared. I observed the following:

{{ $p := "path" }}
{{ relref . $p }}  # emits warning if $p not found
{{ with $p := "path" }}
  {{ relref . $p }}   # No warning
{{ end }}

Any idea what’s behind that difference, and can I get the behavior back?

If $p does not exist, then relref never gets called, therefore no warnings are raised.

Note that the dot . context changes inside a with, so you probably need to modify your relref statement.

Ah, of course! :man_facepalming:

So I guess I’ll do something along the lines of:

{{ $relpath := (relref . $p) }}
{{ with ... }}
{{ end }}