是否可以在Twig中使用本机php函数?

use*_*897 5 php templates function symfony twig

我是Symfony的新手.如何在树枝模板中使用本机php功能?

例如,我想chr在这样的循环中使用该函数:

{% for directory in directories %}
    chr(loop.index)
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

Ahm*_*ani 8

Twig允许您添加功能过滤器.文档中有多个示例.

例如,

  • 是的,更好的是以这种方式处理它.Twig可以轻松扩展,添加功能和过滤器是微不足道的. (4认同)