Escaping colons in YAML

2019-04-18 05:34发布

问题:

Does anyone know how to escape colons in YAML? The key in my yml is the domain with port number, but the yml file isn't working with this setup:

###BEGIN
production:
### THIS IS THE ONE I'm HAVING TROUBLE WITH ###
8.11.32.120:8000: GoogleMapsKeyforThisDomain
exampledomain.com: GoogleMapsAPIKeyforThatDomain

development:
 GoogleMapsAPIKeyforDevelopmentDomain
###END

I'm using a google maps plugin called YM4R that uses a .yml file to select the different Google Maps API key depending on where my app is being hosted...

So, I'm trying to make 8.11.32.120:8000 the key. Any idea how to do this? (It's in the gmaps_api_key.yml file if you care)

回答1:

You'll need to put quotes around the key you're having trouble with. I.e.:

"8.11.32.120:8000": GoogleMapsKeyforThisDomain