adrian5
1
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.
adrian5
3
Ah, of course! 
So I guess I’ll do something along the lines of:
{{ $relpath := (relref . $p) }}
{{ with ... }}
...
{{ end }}