yeci
yeci

Reputation: 3

How to create and pass multiarray in Twig?

How to create and pass multiarray in Twig?

{{ include('box.html.twig', {multi: {aaa: bbb, ccc: ddd}}) }}

Is good but I would like have to many elements in variable multi:

{{ include('box.html.twig', {multi: {aaa: bbb, ccc: ddd}, {aaa: eee, ccc: fff}}) }}

It doesn't work.

{{ include('box.html.twig', {multi: {{aaa: bbb, ccc: ddd}, {aaa: eee, ccc: fff}}}) }}

and:

{{ include('box.html.twig', {multi: [{aaa: bbb, ccc: ddd}, {aaa: eee, ccc: fff}}]) }}

Also doesn't work.

Upvotes: 0

Views: 62

Answers (1)

lalithkumar
lalithkumar

Reputation: 3540

Try like below:

{% include 'box.html.twig' with {'multi': {{'aaa': 'bbb', 'ccc': 'ddd'}, {'aaa': 'eee', 'ccc': 'fff'}}} %}

For more information check https://twig.sensiolabs.org/doc/2.x/tags/include.html

Note:if you are using without quotes php will consider as defined word.

Upvotes: 1

Related Questions