Twig

The flexible, fast, and secure
template engine for PHP

a Symfony Product
Docs invoke
You are reading the documentation for Twig 3.x. Switch to the documentation for Twig 1.x, 2.x.

Questions & Feedback

License

Twig documentation is licensed under the new BSD license.

invoke

3.19

The invoke filter has been added in Twig 3.19.

The invoke filter invokes an arrow function with the given arguments:

1
2
3
4
5
{% set person = { first: "Bob", last: "Smith" } %}
{% set func = p => "#{p.first} #{p.last}" %}

{{ func|invoke(person) }}
{# outputs Bob Smith #}