progest/twig-extension-callfunc

Twig extension to call PHP functions or static methods from templates

1.2 2019-03-21 11:15 UTC

This package is auto-updated.

Last update: 2025-06-22 01:22:53 UTC


README

Twig extension to call PHP functions or static methods from templates

Installation:

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

Usage:

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

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

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