PHP code example of rakit / blade

1. Go to this page and download the library: Download rakit/blade library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rakit / blade example snippets




it\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' ]);



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