【问题标题】:Twig include : use translation in the passed argumentTwig include : 在传递的参数中使用翻译
【发布时间】:2015-11-12 13:19:22
【问题描述】:

这很好用

{% include 'site/snippet.html.twig'
    with {'description': 'Some text'}
%}

但是如何让它工作呢? 使用翻译作为论据

{% include 'site/snippet.html.twig'
    with {'description': '{{ 'solutions.description' | trans }}'}
%}

sn-p.html内容为:

<p>
    {{ description }}
</p>

单独调用翻译{{ 'solutions.description' | trans }}会按预期显示内容。

会是什么语法?

【问题讨论】:

    标签: php symfony twig twig-extension


    【解决方案1】:

    您不需要将字符串包装在一组额外的{{ }} 中。实际上它应该像这样工作:

    with {'description': 'solutions.description'|trans}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-16
      • 1970-01-01
      • 2011-10-11
      • 2021-09-14
      • 2017-05-11
      • 2011-05-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多