PHP code example of fiskhandlarn / blade

1. Go to this page and download the library: Download fiskhandlarn/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/ */

    

fiskhandlarn / blade example snippets


blade('index', ['machine' => 'Voight-Kampff']);

use Fiskhandlarn\Blade;

$blade = new Blade(get_stylesheet_directory() . '/views', get_stylesheet_directory() . '/cache');

echo $blade->render('index', ['machine' => 'Voight-Kampff']);

blade_controller('index', 'Index');

echo $blade->renderController('index', 'Index');

blade_controller('index', 'Index', ['lifespan' => "A coding sequence cannot be revised once it's been established."]);

echo $blade->renderController('index', 'Index', ['lifespan' => "A coding sequence cannot be revised once it's been established."]);

blade_directive('datetime', function ($expression) {
    return " echo with({$expression})->format('Y-m-d H:i:s'); 

$blade->directive('datetime', function ($expression) {
    return " echo with({$expression})->format('Y-m-d H:i:s'); 

{{-- In your Blade template --}}
@php $dateObj = new DateTime('2019-11-01 00:02:42') @endphp
@datetime($dateObj)

// Make variable available in all views
blade_composer('*', function ($view) {
    $view->with(['badge' => 'B26354']);
});

// Make variable available in all views
$blade->composer('*', function ($view) {
    $view->with(['badge' => 'B26354']);
});

// Make variable available in all views
blade_share(['badge' => 'B26354']);

$blade->share(['badge' => 'B26354']);

add_filter('blade/view/paths', function ($paths) {
    $paths = (array) $paths;

    $paths[] = get_stylesheet_directory() . '/views';

    return $paths;
});

add_filter('blade/cache/path', function ($path) {
    $uploadDir = wp_upload_dir();
    return $uploadDir['basedir'] . '/.bladecache/';
});

add_filter('blade/cache/create', '__return_false');

add_filter('blade/controller/namespace', function () {
    return 'MyApp\Controllers';
});