Using TWIG templates
Laravel's Blade templates may be nice but there are times when we need another PHP template library. A popular one is Twig. This recipe will show how to incorporate Twig templates into our Laravel application.
Getting ready
For this recipe, we'll just need a standard Laravel installation.
How to do it…
Follow these steps to complete this recipe:
Open the
composer.json
file and add the following line to therequire
section:"rcrowe/twigbridge": "0.4.*"
In the command line, update composer to install the package:
php composer.phar update
Open the
app/config/app.php
file and, in theproviders
array, add Twig ServiceProvider at the end as follows:'TwigBridge\TwigServiceProvider'
In the command line, run the following command to create our config file:
php artisan config:publish rcrowe/twigbridge
In
routes.php
, create a route as follows:Route::get('twigview', function() { $link = HTML::link('http://laravel.com', 'the Laravel site.'); return View::make('twig')->with('link'...