【问题标题】:symfony2 - twig - difference filter transsymfony2 - twig - 差分过滤器反式
【发布时间】:2015-12-23 11:53:47
【问题描述】:

我想知道{% trans%} lorem ipsum {%endtrans%}{{'lorem ipsum' | trans}}有什么区别

并且在这种情况下使用块{% trans%}

我不明白其中的区别。谢谢

【问题讨论】:

    标签: symfony twig translation


    【解决方案1】:

    根据 symfony 文档

    使用翻译标签或过滤器具有相同的效果,但使用 一个细微的区别:自动输出转义仅适用于 使用过滤器翻译。换句话说,如果你需要确定 您翻译的消息没有转义输出,您必须应用 翻译过滤器后的原始过滤器

    {# text translated between tags is never escaped #}
    {% trans %}
        <h3>foo</h3>
    {% endtrans %}
    
    {# strings and variables translated via a filter are escaped by default #}
    {{ '<h3>bar</h3>'|trans|raw }}
    

    http://symfony.com/doc/current/book/translation.html#twig-templates

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-08
      • 2015-09-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多