covex-nn / twig-callable-bridge-bundle
Provides a simple interface to extend Twig with PHP functions
Installs: 366
Dependents: 6
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.0
- symfony/twig-bundle: ~2.3|~3.0
Requires (Dev)
- apnet/coding-standard: ~2.0
- knplabs/knp-markdown-bundle: ~1.5
- phpunit/phpunit: ~4.0
- symfony/monolog-bundle: ~2.3|~3.0
- symfony/symfony: ~2.3|~3.0
This package is not auto-updated.
Last update: 2022-02-01 12:34:44 UTC
README
This Symfony2 bundle aims to provide a simple interface to extend Twig with PHP functions
Installation
Add requirements to composer.json:
{ "require" : { "covex-nn/twig-callable-bridge-bundle" : "~1.0" } }
Register the bundle
Register the bundle in the AppKernel.php
file
// ...other bundles ... $bundles[] = new Covex\TwigCallableBridgeBundle\CovexTwigCallableBridgeBundle();
Configuration
Add the configuration to config.yml
covex_twig_callable_bridge: functions: uppercase: strtoupper filters: lowercase: strtolower test: numeric: is_numeric
Twig
Use your functions, filters and test in Twig templates:
{{ uppercase('qqq') }} {{ 'WoW'|lowercase }} {% if 1 is numeric %}yes{% else %}no{% endif %}