如何在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
有什么想法吗?
答案 0 :(得分:6)
怎么样,
{% set params = params|merge({'redirect_uri': 'http://site.loc/'}) %}