I’ve got a
data/authors.yaml file with a few nested keys. When somewhere down the tree a key is missing, I get an annoying but not very surprising exception:
<index $.Site.Data "authors" $id "name">: error calling index: index of nil pointer
… if there is
$id, but no
What surprises me, is that if I do the same with
$.Site.Params, it doesn’t throw an exception, which is a desired behavior in this particular case.
Of course, I can wrap it in
Is there a more elegant way to achieve the same behavior as with
$.Site.Params? Out of curiosity, is there any reason for this difference in behavior? In other words, is it a feature or a bug?