covex-nn/twig-callable-bridge-bundle
This Symfony2 bundle aims to provide a simple interface to extend Twig with PHP functions
Add requirements to composer.json:
{
"require" : {
"covex-nn/twig-callable-bridge-bundle" : "~1.0"
}
}
Register the bundle in the AppKernel.php file
// ...other bundles ...
$bundles[] = new Covex\TwigCallableBridgeBundle\CovexTwigCallableBridgeBundle();
Add the configuration to config.yml
covex_twig_callable_bridge:
functions:
uppercase: strtoupper
filters:
lowercase: strtolower
test:
numeric: is_numeric
Use your functions, filters and test in Twig templates:
{{ uppercase('qqq') }}
{{ 'WoW'|lowercase }}
{% if 1 is numeric %}yes{% else %}no{% endif %}
How can I help you explore Laravel packages today?