Forum: Ruby on Rails Escaping colons in YAML

9a71afcb133b3c1a779a63835370582f?d=identicon&s=25 Dustin Anderson (dkanders)
on 2007-10-08 21:21
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!
413faf211358af7cae68c1f2137de0f8?d=identicon&s=25 Mel Riffe (Guest)
on 2007-10-08 21:43
(Received via mailing list)
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
9a71afcb133b3c1a779a63835370582f?d=identicon&s=25 Dustin Anderson (dkanders)
on 2007-10-08 22:50
Mel Riffe 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...
1f2eadfb41362800ebc2cf211b91d0f7?d=identicon&s=25 javier ramirez (Guest)
on 2007-10-09 00:21
(Received via mailing list)
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
Dd2d775dea75b381edb1bbf0600a0907?d=identicon&s=25 Marnen Laibow-Koser (marnen)
on 2007-10-09 17:54
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
marnen@marnen.org
4e04783a21b6fa7044b6474d5364f539?d=identicon&s=25 Chris v. (chris_v)
on 2013-01-28 15:16
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.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.