digivo/laravel-string-blade-compiler

将字符串渲染成Blade模板

1.3.1 2019-09-19 19:21 UTC

This package is not auto-updated.

Last update: 2024-09-28 19:31:07 UTC


README

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

将字符串渲染成Blade模板

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

安装(Laravel 5.x)

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

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

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

'Digivo\StringBladeCompiler\StringBladeCompilerServiceProvider',

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

'StringView'          => 'Digivo\StringBladeCompiler\Facades\DigivoView',

您还需要发布配置文件

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许可证授权