从字符串而不是文件渲染刀片 [英] Render Blade from string instead of File

查看:67
本文介绍了从字符串而不是文件渲染刀片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何呈现包含刀片语法的字符串?

How can I render an string which contains blade syntax?

View::make('directory.file-name')->with('var', $var);  // Usual usage

View::render('{{$var}}')->with('var', $var); // Like this for Example

我使用编写的脚本来生成刀片语法,如果可能的话,我想将其输出直接提供给刀片引擎.

I use wrote an script that produces blade syntax and I want to give it's output directly to blade engine if possible.

谢谢

推荐答案

希望这会有所帮助,

https://github.com/TerrePorter/StringBladeCompiler

这是下一个链接的分支,该链接删除了db模型的要求,并将其替换为需要三个必需键("template","cache_key","updated_at")的数组,而不是完整的Eloquent模型.

This is a fork of the next link that removes the db model requirement and replaces it with a array that requires three required keys ('template', 'cache_key', 'updated_at') instead of the full Eloquent model.

https://github.com/Flynsarmy/laravel-db-blade-compiler

这使用Eloquent模型获取模板.

This uses a Eloquent model to get the template.

这篇关于从字符串而不是文件渲染刀片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆