定制 terranc/blade 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

terranc/blade

最新稳定版本:0.1.0

Composer 安装命令:

composer require terranc/blade

包简介

an independent version of laravel view template - blade

README 文档

README

Use Laravel Blade templates without the full Laravel framework.(component & slot support)

Installation

composer require terranc/blade

Usage

<?php
$path = ['/view_path'];         // your view file path, it's an array
$cachePath = '/cache_path';     // compiled file path

$compiler = new \terranc\Blade\Compilers\BladeCompiler($cachePath);

// you can add a custom directive if you want
$compiler->directive('datetime', function($timestamp) {
    return preg_replace('/(\(\d+\))/', '<?php echo date("Y-m-d H:i:s", $1); ?>', $timestamp);
});

$engine = new \terranc\Blade\Engines\CompilerEngine($compiler);
$finder = new \terranc\Blade\FileViewFinder($path);

// if your view file extension is not php or blade.php, use this to add it
$finder->addExtension('tpl');

// get an instance of factory
$factory = new \terranc\Blade\Factory($engine, $finder);

// render the template file and echo it
echo $factory->make('hello', ['a' => 1, 'b' => 2])->render();

You can enjoy almost all the features of blade with this extension. However, remember that some of exclusive features are removed.

You can't:

  • use @inject @can @cannot @lang in a template file
  • add any events or middleawares

Documentation: http://laravel.com/docs/5.4/blade

Thanks for Laravel and it authors. That is a great project.

For ThinkPHP

https://github.com/terranc/think-blade

Reference

XiaoLer/blade

统计信息

  • 总下载量: 1.66k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 39
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-04