mejta/standalone-blade

This package is abandoned and no longer maintained. No replacement package was suggested.

v5.6.1 2018-06-20 08:40 UTC

This package is auto-updated.

Last update: 2020-08-24 21:17:42 UTC


README

This project provide Blade as a standalone library that works with 5.6 Laravel Blade. See blade documentation: https://laravel.com/docs/5.6/blade

Compatible with

  • PHP >= 7.1

Instalation

composer require mejta/standalone-blade

Usage

use Mejta\StandaloneBlade;

$viewDirs = [
    __DIR__ . '/views',
];

$cacheDir = __DIR__ . '/cache';

$engine = new StandaloneBlade($viewDirs, $cacheDir);

// Define custom directives
$engine->directive('datetime', function($expression) {
    return "<?php echo ($expression)->format('m/d/Y H:i'); ?>";
});

// Define custom if statements
$engine->if('env', function($environment) {
    return app()->environment($environment);
});

// Share variables with all templates
$engine->share('key', 'value');

// Render template
echo $engine->render('page-template', [
    'title' => 'Page title',
    'content' => 'Some example page content',
]);