2017 © Pedro Peláez
 

library ronin-blade

Laravel Blade template engine as a standalone component

image

atijust/ronin-blade

Laravel Blade template engine as a standalone component

  • Sunday, September 20, 2015
  • by atijust
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Ronin Blade

Build Status Scrutinizer Code Quality Code Coverage License, (*1)

Laravel Blade template engine as a standalone component., (*2)

make('index', ['message' => 'Hello, world!'])->render();
```

## Installation

Require this package in your composer.json and run composer update command.

```json
{
    "require": {
        "atijust/ronin-blade": "dev-master@dev"
    }
}
```

## Usage

`\Ronin\Blade::make()` returns a instance of `Illuminate\View\Factory`.

```php
$blade = Ronin\Blade::make(__DIR__ . '/views', __DIR__ . '/cache');
echo get_class($blade); // => Illuminate\View\Factory
```

You can use all blade features.

```php
// 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 "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., (*3)

$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

License

Ronin Blade is open-sourced software licensed under the MIT license., (*4)

The Versions

20/09 2015

dev-master

9999999-dev

Laravel Blade template engine as a standalone component

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar atijust

laravel templating template blade view