In Twig, there is a strict_variables setting which causes this access to return null (https://twig.symfony.com/doc/3.x/templates.html#variables) and in twig I could check for the existence of the variable without triggering the error.
Specifically, I'm using this package to render arbitrary json data provided as map[string]interface{}, for example:
{ "data": { "foo": "bar" }}
and I'm trying to handle the expression {{ data.missing }} without running into the error. I would like it to just output empty string if missing is not defined on data.
Am I overlooking a way to do this? Thank you for your help!
Hi there, (love this package, thank you soooo much for it!!)
I'm getting an error when I access a missing key in a map (originating here: https://github.com/tyler-sommer/stick/blob/master/value.go#L242) and I don't seem to find a way to suppress/avoid it.
In Twig, there is a
strict_variables
setting which causes this access to return null (https://twig.symfony.com/doc/3.x/templates.html#variables) and in twig I could check for the existence of the variable without triggering the error.Specifically, I'm using this package to render arbitrary json data provided as
map[string]interface{}
, for example:and I'm trying to handle the expression
{{ data.missing }}
without running into the error. I would like it to just output empty string ifmissing
is not defined ondata
.Am I overlooking a way to do this? Thank you for your help!