Updating object properties in twig

后端 未结 6 816
借酒劲吻你
借酒劲吻你 2020-12-29 18:30

Is there a way to update an object\'s property in twig?

An object like the following is passed to twig:

object
   property1
   property2
6条回答
  •  情歌与酒
    2020-12-29 19:10

    You can do it by merging objects:

    {% set object = object|merge({'property1': 'somenewvalue'}) %}
    

提交回复
热议问题