wake / silex-twig-helper
Provide a better way to use Twig for Silex. This is base on Silex/Application/TwigTrait.php by Fabien Potencier and add some helpful functions.
dev-master
2018-07-04 14:46 UTC
Requires
- silex/silex: >=1
- symfony/twig-bridge: >=2
- twig/twig: >=1
This package is auto-updated.
Last update: 2024-10-29 04:42:09 UTC
README
Provide a better way to use Twig with Silex, base on Silex/Application/TwigTrait.php by Fabien Potencier.
Usage
$app->get('/hello/{name}', function ($name) use ($app) { // Original way /* return $app->render ('hello.twig', [ 'name' => $name, ]); */ // A better way return $app ->assign ('name', $name) ->render ('hello.twig'); // Or $app->assign ('name', $name); // some code // ... return $app->render ('hello.twig'); });
Installation
Add in your composer.json
with following require entry:
{ "require": { "wake/Silex-Twig-Helper": "*" } }
or using composer:
$ composer require wake/Silex-Twig-Helper:*
then run composer install
or composer update
.
Trait
class MyApplication extends Silex\Application { use Silex\Application\TwigHelperTrait; }
Feedback
Please feel free to open an issue and let me know if there is any thoughts or questions 😃
License
Released under the MIT license