定制 atijust/ronin-blade 二次开发

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

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

atijust/ronin-blade

Composer 安装命令:

composer require atijust/ronin-blade

包简介

Laravel Blade template engine as a standalone component

README 文档

README

Build Status Scrutinizer Code Quality Code Coverage License

Laravel Blade template engine as a standalone component.

<?php
require_once __DIR__ . '/vendor/autoload.php';

$blade = Ronin\Blade::make(__DIR__ . '/views', __DIR__ . '/cache');
echo $blade->make('index', ['message' => 'Hello, world!'])->render();

Installation

Require this package in your composer.json and run composer update command.

{
    "require": {
        "atijust/ronin-blade": "dev-master@dev"
    }
}

Usage

\Ronin\Blade::make() returns a instance of Illuminate\View\Factory.

$blade = Ronin\Blade::make(__DIR__ . '/views', __DIR__ . '/cache');
echo get_class($blade); // => Illuminate\View\Factory

You can use all blade features.

// Add a piece of shared data to the environment.
$blade->share('defaultTitle', 'Ronin Blade');

// Register a view composer event.
$blade->composer('index', 'IndexViewComposer');

// Register a handler for custom directives.
$blade->getEngineResolver()->resolve('blade')->getCompiler()->directive(
    'datetime',
    function($expression) {
        return "<?php echo with{$expression}->format('m/d/Y H:i'); ?>";
    }
);

// Get the evaluated view contents for the given view.
$view = $blade->make('index');

By default, view composer and view creater are resolved by the ronin's internal container. If you want to use your own container, set the third parameter of \Ronin\Blade::make() to any container you like.

$container = new \Illuminate\Container\Container();
$container->singleton('IndexViewComposer', function () {
    return new IndexViewComposer();
});

$blade = \Ronin\Blade::make(__DIR__ . '/views', __DIR__ . '/cache', $container);
$blade->composer('index', 'IndexViewComposer'); // Resolved by $container

License

Ronin Blade is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-18