Blade Use Laravel Blade templates as a standalone component without the full Laravel framework

Getting Started

Instance

Static

Directives

Assets

The Blade syntax available via this library has been extended to make asset inclusion easier.

@css("/css/styles.css")

The above command will generate the following html:

<link rel='stylesheet' type='text/css' href='/css/styles.css'>

However the path is optional (“/css/” is assumed):

@css("styles.css")

The extension is also optional (“.css” is assumed):

@css("styles")

There is also a javascript command which works in the same way:

@js("/js/resizer.js")
@js("resizer.js")
@js("resizer")

The above commands will all generate the following html:

<script type='text/javascript' src='/js/resizer.js'></script>

You can customer the default path like so:

use duncan3dc\Laravel\BladeInstance;
use duncan3dc\Laravel\Directives;

$directives = (new Directives)
    ->withCss("assets/css")
    ->withJs("assets/js");

$blade = new BladeInstance("/var/www/views", "/var/www/cache/views", $directives);

Or disable them:

$directives = (new Directives)
    ->withoutCss()
    ->withoutJs();