I have a resource
$res that is loaded via
$page.Resources.GetMatch. It might be nil, because the resource might not exist.
Now I want the following expression:
(cond $res (printf "%s %sw," $res.RelPermalink $res.Width) "")
Does not work,
cond expects a bool (although
(cond (not $res) seems to be valid,
cond expects a bool but
not does not?).
So let’s booleanize the parameter:
(cond (not (not $res)) (printf "%s %sw," $res.RelPermalink $res.Width) "")
execute of template failed: template: partials/mysite/mylayout.html:43:84: executing "partials/mysite/mylayout.html" at <$res.RelPermalink>: nil pointer evaluating resource.Resource.RelPermalink
Uh, I’m explicitly checking if the resource is
nil or not, but I get a nil pointer exception anyway?