I am trying to reference values from an external YAML file in my Gruntfile. I am reading the YAML with no problems using:
external_config: grunt.file.readYAML('config.yml')
My config.yml
file contains the following:
foo: abc
:bar: def
I can use <% %>
templating to get the value for foo
in my Gruntfile just fine:
foo: '<%= external_config.foo %>'
But I can't seem to be able to get the value for :bar
. I have learned the colon in front of the key denotes a symbol (Colon in the front: YAML syntax), but I have no idea how to get to its value from my Gruntfile.
bar: '<%= external_config.bar %>' // doesn't work
bar: '<%= external_config.:bar %>' // throws error "Unexpected token :"
bar: '<%= external_config.\:bar %>' // throws error "Unexpected token :"
I cannot modify the YAML file. Is there a way to do this?