Twig service for Caffeina Core Views

Installs: 5 289

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 4

Forks: 0

Open Issues: 0

Type:core-bundle

1.2.0 2016-03-31 15:11 UTC

This package is auto-updated.

Last update: 2024-12-16 21:02:39 UTC


README

Scrutinizer Code Quality Build Status Total Downloads Latest Stable Version Latest Unstable Version License

Twig bridge for Core View.

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>