views:

64

answers:

0

So I'd like to be able to add a longer block of text to a YAML locale file in Rails. However, the YAML parser gives syntax errors for blocks that appear to be fine! I've read through the Ruby YAML cookbook and it seems like these examples below should all work, but they don't.

config/locales/tx.yml

This one works fine:

tx:
  states:
    show:
      state_population: "2009 est. pop.: 24,782,302 (cit. <a href=\"http://quickfacts.census.gov/qfd/states/48000.html\"&gt;Census.gov&lt;/a&gt;"
      state_pop_per_upper_chamber_member: "Each senator serves a four-year term and represents approx. 774,447 Texans"

...but is ugly.

None of these work...

tx:
  states:
    show:
      state_population: |
        2009 est. pop.: 24,782,302 (cit. <a href="http://quickfacts.census.gov/qfd/states/48000.html"&gt;Census.gov&lt;/a&gt;
      state_pop_per_upper_chamber_member: "Each senator serves a four-year term and represents approx. 774,447 Texans"


tx:
  states:
    show:
      state_population: >
        2009 est. pop.: 24,782,302 (cit. <a href="http://quickfacts.census.gov/qfd/states/48000.html"&gt;Census.gov&lt;/a&gt;
      state_pop_per_upper_chamber_member: "Each senator serves a four-year term and represents approx. 774,447 Texans"

tx:
  states:
    show:
      state_population: |
        "2009 est. pop.: 24,782,302 (cit. <a href=\"http://quickfacts.census.gov/qfd/states/48000.html\"&gt;Census.gov&lt;/a&gt;"
      state_pop_per_upper_chamber_member: "Each senator serves a four-year term and represents approx. 774,447 Texans"

tx:
  states:
    show:
      state_population: |
        2009 est. pop.\: 24,782,302 (cit. <a href="http://quickfacts.census.gov/qfd/states/48000.html"&gt;Census.gov&lt;/a&gt;
      state_pop_per_upper_chamber_member: "Each senator serves a four-year term and represents approx. 774,447 Texans"