rakit / blade by emsifa

Blade template engine outside laravel
101
2
3
Package Data
Maintainer Username: emsifa
Maintainer Contact: emsifa@gmail.com (Muhammad Syifa)
Package Create Date: 2016-01-14
Package Last Update: 2017-02-12
Language: PHP
License: MIT
Last Refreshed: 2024-11-23 03:17:36
Package Statistics
Total Downloads: 101
Monthly Downloads: 2
Daily Downloads: 0
Total Stars: 2
Total Watchers: 3
Total Forks: 1
Total Open Issues: 0

Rakit Blade

Build Status License

Blade Template Engine outside Laravel Framework.

Usage Example

<?php

require('vendor/autoload.php');

use Rakit\Blade\Blade;

$view_paths = [ __DIR__.' /views' ];
$view_cache_path = __DIR__.'/cache/views';

$blade = new Blade($view_paths, $view_cache_path);

// then, you can render blade file using `render` method
$rendered = $blade->render('myview');

// or render with data
$rendered = $blade->render('myview', [ 'message' => 'foobar' ]);

Extending Compiler

You can extend compiler using extend method.


// register @upper() compiler 
$blade->extend(function($view, $compiler) {
    $pattern = $compiler->createMatcher('upper');
    return preg_replace($pattern, '$1<?php echo strtoupper($2); ?>', $view);
});

// you can use it in your view file by @upper('my string')