progest/twig-extension-callfunc

Twig 扩展,用于从模板中调用 PHP 函数或静态方法

1.2 2019-03-21 11:15 UTC

This package is auto-updated.

Last update: 2024-09-21 23:40:36 UTC


README

Twig 扩展,用于从模板中调用 PHP 函数或静态方法

安装

# $twig being your Twig_Environment object
$twig->addExtension(new \ProGest\Twig\CallFuncExtension());

用法

# Call function
{{ callfunc('myFunction') }}

# Call static method
{{ callfunc('myClass::myStaticMethod') }}

# Pass one or multiple arguments
{{ callfunc('myFunction', 8546) }}
{{ callfunc('myFunction', ['testValue', 9897]) }}