【问题标题】:How to set array value in twig template如何在树枝模板中设置数组值
【发布时间】:2014-01-14 12:07:52
【问题描述】:

如何通过 twig 模板中的字符串索引更改数组值?我正在尝试:

{% do params['redirect_uri'] = 'http://site.loc/' %}

但我收到 nex 错误:

Unexpected token "operator" of value "=" ("end of statement block" expected) in
BWUserBundle:User/social:sign-in-thumbs.html.twig at line 4

我也在尝试:

{% set params['redirect_uri'] = 'http://site.loc/' %}

但也有错误:

Unexpected token "punctuation" of value "[" ("end of statement block" expected) in 
BWUserBundle:User/social:sign-in-thumbs.html.twig at line 4

有什么想法吗?

【问题讨论】:

    标签: arrays symfony twig


    【解决方案1】:

    怎么样,

    {% set params = params|merge({'redirect_uri': 'http://site.loc/'}) %}
    

    【讨论】:

    • Unexpected token "punctuation" of value "." ("end of statement block" expected) in BWUserBundle:User/social:sign-in-thumbs.html.twig at line 4
    猜你喜欢
    • 2013-08-07
    • 2017-10-14
    • 2012-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-11
    • 1970-01-01
    相关资源
    最近更新 更多