covex-nn/twig-callable-bridge-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

Provides a simple interface to extend Twig with PHP functions

1.1.0 2016-07-08 07:58 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:34:44 UTC


README

Build Status SensioLabsInsight

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 %}