How to print the value of a key containing dots

As @martin-ghallager said, one needs to use an external function to access those elements.

Helpfully, the standard library already provides the index function (which does exactly what Martin’s dotNotation function does).

To use it just write:

{{ index .Data "core.value" }}

The index function will return a default value in case the key is not present. This works if your dictionary has homogeneous data, however it will return the wrong value when it is heterogeneous. In such a case you can explicitly set the default with:

{{ 0 | or (index .Data "core.value") }}

Leave a Comment