Package Data | |
---|---|
Maintainer Username: | atijust |
Maintainer Contact: | tsujita.shou@gmail.com (atijust) |
Package Create Date: | 2015-09-18 |
Package Last Update: | 2015-09-19 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-18 03:02:44 |
Package Statistics | |
---|---|
Total Downloads: | 21 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 1 |
Total Open Issues: | 0 |
Laravel Blade template engine as a standalone component.
<?php
require_once __DIR__ . '/vendor/autoload.php';
$blade = Ronin\Blade::make(__DIR__ . '/views', __DIR__ . '/cache');
echo $blade->make('index', ['message' => 'Hello, world!'])->render();
Require this package in your composer.json and run composer update command.
{
"require": {
"atijust/ronin-blade": "dev-master@dev"
}
}
\Ronin\Blade::make()
returns a instance of Illuminate\View\Factory
.
$blade = Ronin\Blade::make(__DIR__ . '/views', __DIR__ . '/cache');
echo get_class($blade); // => Illuminate\View\Factory
You can use all blade features.
// Add a piece of shared data to the environment.
$blade->share('defaultTitle', 'Ronin Blade');
// Register a view composer event.
$blade->composer('index', 'IndexViewComposer');
// Register a handler for custom directives.
$blade->getEngineResolver()->resolve('blade')->getCompiler()->directive(
'datetime',
function($expression) {
return "<?php echo with{$expression}->format('m/d/Y H:i'); ?>";
}
);
// Get the evaluated view contents for the given view.
$view = $blade->make('index');
By default, view composer and view creater are resolved by the ronin's internal container. If you want to use your own container, set the third parameter of \Ronin\Blade::make()
to any container you like.
$container = new \Illuminate\Container\Container();
$container->singleton('IndexViewComposer', function () {
return new IndexViewComposer();
});
$blade = \Ronin\Blade::make(__DIR__ . '/views', __DIR__ . '/cache', $container);
$blade->composer('index', 'IndexViewComposer'); // Resolved by $container
Ronin Blade is open-sourced software licensed under the MIT license.