Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

eval returns undefined if the string starts with a comment #37

Open
fredreichbier opened this issue Nov 16, 2011 · 2 comments
Open

eval returns undefined if the string starts with a comment #37

fredreichbier opened this issue Nov 16, 2011 · 2 comments

Comments

@fredreichbier
Copy link

(coffeescript)

yaml = require "yaml"

data1 = yaml.eval """
# This is a comment.
Hey: There
"""
data2 = yaml.eval """
Hey: There
"""
console.log data1
console.log data2

gives:

undefined
{ Hey: 'There' }

Not sure if that's expected behaviour. I'll probably have a look into the code for that. ;)

@cristobal
Copy link

This is not the expected behaviour added some yml files from another project and parsed with other yaml parses it works fine. As far as it seems # comments should be possible to add anywhere in the document without it interfering with the rest of the data in the yaml document. See http://www.yaml.org/spec/1.0/#id2489959

@nathankleyn
Copy link

Having this very same issue, took a while to figure out exactly what the issue was. Have worked around it for now by adding a dummy key to the top of my YAML file so I can keep the descriptive comments.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants