Escaping colons in YAML

Hello,

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)

Thanks!

Not sure if this will work, but isn’t YAML processed by ERB? Could you
use
something like:

<%= “8.11.32.120:8000” %>: GoogleMapsKeyforThisDomain

–Mel

Mel R. wrote:

<%= “8.11.32.120:8000” %>: GoogleMapsKeyforThisDomain

Thanks Mel - that didn’t work… but wouldn’t that just spit out the
same text to YML?

I’m wondering if I’m expecting Ym4R to be able to handle multiple
domains and it can’t… any other ideas? Thanks again…

Hi,

Does anyone know how to escape colons in YAML?
you can double-quote the whole string. I have tried it for quoting
values anyway, never keys, so not sure if it will work for you

this works for sure

key: “a value with : in the middle”

regards,

javier ramirez

javier ramirez wrote:

you can double-quote the whole string. I have tried it for quoting
values anyway, never keys, so not sure if it will work for you

Double-quoted keys should work too. See section 4.5.1.1 of the YAML
spec.

Best.
Marnen Laibow-Koser
[email protected]

In my perl code I found that a double-qouted string may not contain a
colon, but in a single quoted string it works without using any escape.
Success.