PHP code example of ajiho / think-blade

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

    

ajiho / think-blade example snippets




return [
    //原始标记
    'rawTags' => ['{!!', '!!}'],

    //内容标记
    'contentTags' => ['{{', '}}'],

    //转移标记
    'escapedTags' => ['{{{', '}}}'],

    // 模板目录名
    'view_dir_name' => 'view',

    // 模板编译目录名
    'compile_dir_name' => 'templates_compile',
];

use ajiho\blade\facade\Blade;


//全局分配变量
Blade::share('user2', '123');


//给指定的模板分配变量
Blade::composer("main.sidebar", function($view) {
    $view->with("links", 'github.com');
});

// 定义指令
Blade::directive('strlen', function ($parameter) {
    return " echo strlen($parameter)