所以我希望能够在Rails中的YAML语言环境文件中添加更长的文本块。 但是,YAML解析器为看起来很好的块提供了语法错误!我已经阅读了Ruby YAML食谱,看起来下面的这些例子都可行,但它们没有。
这个很好用:
tx:
states:
show:
state_population: "2009 est. pop.: 24,782,302 (cit. <a href=\"http://quickfacts.census.gov/qfd/states/48000.html\">Census.gov</a>"
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">Census.gov</a>
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">Census.gov</a>
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\">Census.gov</a>"
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">Census.gov</a>
state_pop_per_upper_chamber_member: "Each senator serves a four-year term and represents approx. 774,447 Texans"
答案 0 :(得分:1)
tx:
states:
show:
state_population: >
2009 est. pop.: 24,782,302
(cit.
<a href=\"http://quickfacts.census.gov/qfd/states/48000.html\">Census.gov</a>)
state_pop_per_upper_chamber_member: "Each senator serves a four-year term and represents approx. 774,447 Texans"