Rub*_*tic 3 syntax yaml multiline
多行上的换行符似乎不适合我:
就像是:
intro: |
We are happy that you are interested in
and
more
Run Code Online (Sandbox Code Playgroud)
和+需要在换行符上,但是失败。
intro: |
| We are happy that you are interested in
| and
| more
Run Code Online (Sandbox Code Playgroud)
要么
intro: |
We are happy that you are interested in \n
and
more <2 spaces >
another one
Run Code Online (Sandbox Code Playgroud)
都失败了。
如何在Yaml文本块中正确包含多行?
我在Rails应用程序的HAML视图中使用它
= t(“ mailer.beta_welcome.intro”)
但是没有以这种方式打印换行符,我是否需要用原始内容或其他内容输出不同的内容?
您的第一个示例工作正常
foo.yml
intro: |
We are happy that you are interested in
and
more
Run Code Online (Sandbox Code Playgroud)
foo.rb
require 'yaml'
puts YAML.load_file('foo.yml').inspect
Run Code Online (Sandbox Code Playgroud)
输出量
{"intro"=>"We are happy that you are interested in\nand \nmore\n"}
Run Code Online (Sandbox Code Playgroud)
呃..在对不同的关键字进行更多挖掘后我发现
= simple_format(t("mailer.beta_welcome.intro"))
Run Code Online (Sandbox Code Playgroud)
虽然这看起来很愚蠢,但我目前还没有看到解决方法