buchin/slim-blade-view
Blade for Slim Framework 3
Usage
In index.php set up the blade container:
$container = $app->getContainer();
$blade = new \Slim\Views\Blade(
'/path/to/views/folder',
'/path/to/cache/folder'
);
// [optional] insert custom directive here
$container['blade'] = $blade;
Example code to render index.blade.php in route:
return $this->blade->render($response, 'index', $args);
Advanced: Custom directive:
$container = $app->getContainer();
$blade = new \Slim\Views\Blade(
'/path/to/views/folder',
'/path/to/cache/folder'
);
// example directive here, usage: @helloWorld
$blade->getRenderer()->getCompiler()->directive('helloWorld', function(){
return "<?php echo 'Hello World'; ?>";
});
$container['blade'] = $blade;
$app->run();
If you like to build custom directive using $app:
$app->getContainer()['blade']->getRenderer()->getCompiler()->directive('helloWorld', function(){
return "<?php echo 'Hello My Second World'; ?>";
});
Related Packages
jenssegers/blade
The standalone version of Laravel's Blade templating engine for use outside of L...
1,397,852
859
eftec/bladeone
The standalone version Blade Template Engine from Laravel in a single php file
11,038,022
829
Version History
| Version | Released | Laravel | License |
|---|---|---|---|
| 0.1.1 | 5.* | MIT | |
| 0.1 | 5.* | MIT |