问题
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
回答2:
To answer a comment another way for list items like:
- sed -i "s/driver: .*/driver: pdo_$DB/" etc/config.yaml
is to write them as:
- >-
sed -i "s/driver: .*/driver: pdo_$DB/" etc/config.yaml
or as:
- 'sed -i "s/driver: .*/driver: pdo_$DB/" etc/config.yaml'
来源:https://stackoverflow.com/questions/14873227/escaping-colons-in-yaml