如何设置在树枝模板数组值 [英] How to set array value in twig template

查看:145
本文介绍了如何设置在树枝模板数组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能在树枝模板,通过字符串索引改变我的数组值?我想:

How I can change my array value by string index in twig template? I'm trying:

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

但我得到NEX错误:

but I get nex error:

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

任何想法?

推荐答案

怎么样,

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

这篇关于如何设置在树枝模板数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆