caffeina-core / twig
Twig service for Caffeina Core Views
Installs: 5 285
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Type:core-bundle
Requires
- php: >=5.4
- caffeina-core/core: *
- twig/twig: *
This package is auto-updated.
Last update: 2024-11-16 20:48:55 UTC
README
Installation
Install via composer:
$ composer require caffeina-core/twig -o
Twig
Twig documentation : http://twig.sensiolabs.org/documentation
Twig Core\View Extras
Adding a Twig Filter
View::addFilter('rot13',function($text){ return str_rot13($text); });
<li>test = {{ test|rot13 }}</li>
Outputs :
<li>test = grfg</li>
Adding global constants
View::addGlobals([ 'BASE_URL' => '/site/', 'ASSETS_URL' => '/site/assets/', ]);
<script src="{{ ASSETS_URL }}js/main.js"></script>
Adding a Twig Function
View::addFunction('myFunction',function($a,$b,$c){ return $a + $b + $c; });
Value = <b>{{ myFunction(1,2,3) }}</b>
Outputs :
Value = <b>6</b>