定制 sngrl/string-blade-compiler 二次开发

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

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

sngrl/string-blade-compiler

Composer 安装命令:

composer require sngrl/string-blade-compiler

包简介

Render Blade templates from string variable

README 文档

README

Blade is a extremly simple, yet powerful templating engine provided with Laravel. Unfortunately, the "out of the box," he can only work with files on the hard drive, while it may be necessary to compile template of the string variable. This package allow for a generic array of the required fields to generates and return a compiled view from a blade-syntax template.

This repository is a fork of the https://github.com/TerrePorter/StringBladeCompiler which in turn was formed from https://github.com/Flynsarmy/laravel-db-blade-compiler which uses Eloquent model to pass in a template.

Author of the original laravel-db-blade-compiler - Flyn San (flynsarmy@gmail.com) Author of the StringBladeCompiler - Terre Porter (tporter@webpage-builders.com)

This package was created to import to the site packagist.org and allow installation through Composer (https://getcomposer.org/).

Installation

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

	"require": {
        /*** Some others packages ***/
		"sngrl/string-blade-compiler": "dev-master",
	},

Or just run this in console:

composer require sngrl/string-blade-compiler:dev-master

After updating composer, add the ServiceProvider to the "providers" array in app/config/app.php:

	'providers' => array(
        /*** Some others providers ***/
        'sngrl\StringBladeCompiler\StringBladeCompilerServiceProvider',
    ),

There is no need to add a Facade to the aliases array in the same file as the service provider, this is being included automatically in the ServiceProvider.

Usage

This package offers a StringView facade with the same syntax as View but accepts a Array or Array Object instance instead of path to view.

return StringView::make(
                array(
                    // this actual blade template
                    'template'  => '{{ $token1 }}',
                    // this is the cache file key, converted to md5
                    'cache_key' => 'my_unique_cache_key',
                    // timestamp for when the template was last updated, 0 is always recompile
                    'updated_at' => 1391973007
                ),
                array(
                    'token1'=> 'token 1 value'
                )
        );

Force compile method:

return StringView::force('{{ $token1 }}', array('token1'=> 'token 1 value'));

License

string-blade-compiler is open-sourced software licensed under the MIT license

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-09-10