Use PHP function in TWIG?(在 TWIG 中使用 PHP 函数?)
问题描述
在 PHP 模板中我可以使用 php 函数,例如:
In PHP templates I can use php functions, for example:
foreach ($users as $user){
echo someFunction($user->getName());
}
如何在 TWIG 中制作它?
How can I make it in TWIG?
{% for user in users %}
* {{ user.name }}
{% else %}
No user have been found.
{% endfor %}
我如何做到这一点?
推荐答案
你需要的是函数或 过滤器.您可以使用示例轻松添加这些内容.
What you need are functions or filters. You can easily add these using the examples.
这篇关于在 TWIG 中使用 PHP 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!