【问题标题】:symfony yaml: keep new lines (literal)symfony yaml:保持新行(字面量)
【发布时间】:2018-02-02 14:56:47
【问题描述】:

我正在尝试在 yaml 文件中保留换行符。 在 messages.en.yml 文件中,我有。

test:|
  Here is line 1
  Here is line 2

在 form.html.twig 中:

{{'测试'|翻译}}

两条线都呈现在同一条线上。 这里是第 1 行 这里是第 2 行

this link 中解释了 Yaml 的文字样式。 和in this other one,它说“显着缺乏的功能是:文档指令,多行引用消息......”

那么在 Symfony Yaml 中是否可以使用多行?如何?

【问题讨论】:

    标签: symfony yaml multiline


    【解决方案1】:

    你可以使用|nl2brfilter

    {{ 'test'|trans|nl2br }}
    

    或者,如果您确定您的翻译不会被任何用户更改,您可以在翻译中使用一些 html。

    test:|
      Here is line 1<br/>
      Here is line 2<br/>
      <br/><br/>
      Here is line 5
    

    然后

    {{ 'test'|trans|raw }}
    

    【讨论】:

      猜你喜欢
      • 2017-08-20
      • 2011-04-14
      • 2019-06-10
      • 2015-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多