How to use Blade Template Engine
ikandar edited this page Nov 11, 2014
·
6 revisions
Blade is a Template Engine use natively in Laravel. To use this package in your Panada project you can install it via composer. To get it works follow this steps:
- Go to your root project and run:
composer require philo/laravel-blade:2.*
We use package from Philo since it modified to works as a standalone component.
- Create new folder within your app project and named it "cache". Your app folders will looks like:
config Controllers Libraries Models Modules views
- Create a blade template file within views folder, for example:
// views/hello.blade.php
Hello, {{{ $name }}}.
The current UNIX timestamp is {{{ time() }}}
- Create a method in a controller who called this blade package:
<?php
namespace Controllers;
use Resources;
use Philo\Blade\Blade;
class Home extends Resources\Controller
{
public function index()
{
Resources\Import::composer();
$views = APP . 'views';
$cache = APP . 'cache';
$blade = new Blade($views, $cache);
echo $blade->view()->make('hello', array('name'=>'Mandriva'));
}
}
- Call this method via browser to test your app.