Escaping colons in YAML

一个人想着一个人 提交于 2019-12-22 01:33:19

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!