bilaliqbalr/laravel-string-blade-compiler

将字符串渲染为Blade模板

1.3 2017-08-15 06:05 UTC

This package is auto-updated.

Last update: 2024-09-15 14:57:54 UTC


README

最初是从Flynsarmy/laravel-db-blade-compiler分叉而来

将字符串渲染为Blade模板

该包从提供的字符串生成并返回编译后的视图

安装(Laravel 5.4.x)

在composer.json中添加此包并运行composer update(或直接运行composer require bilaliqbalr/laravel-string-blade-compiler:1.*

"bilaliqbalr/laravel-string-blade-compiler": "1.*"

更新composer后,将ServiceProvider添加到app/config/app.php中的providers数组中

Bilaliqbalr\StringBladeCompiler\StringBladeCompilerServiceProvider::class,

并将Facade添加到同一文件中的aliases数组中

'StringView'          => Bilaliqbalr\StringBladeCompiler\Facades\StringView::class,

还需要发布配置文件

php artisan vendor:publish

用法

此包提供了一个与View语法相同的StringView外观,但接受字符串而不是视图路径。

return StringView::make('@if ($foo == "Bar") foo is Bar @else foo is not Bar @endif')->with(['foo' => 'Bar'])->render();

许可协议

laravel-string-blade-compiler是开源软件,许可协议为MIT许可协议