加载带有.html扩展名的laravel视图 [英] Loading a laravel view with .html extension
问题描述
Laravel是否可以加载带有.html扩展名的视图模板?
Is it possible to have Laravel load view templates with a .html extension?
我正在重建一个现有的应用程序,该应用程序具有一堆由用户上传的.html文件.这是一种多租户应用程序,每个用户都可以通过上传模板来控制其区域的外观.
I'm rebuilding an existing app that has a bunch of .html files that are uploaded by users. It's a sort of multi-tenant application where each user can control the look and feel of their area by uploading templates.
我需要重建应用程序并使更改对用户完全透明,因此我想保留.html扩展名.
I need to rebuild the app and make the change completely transparent to the users so I'd like to keep the .html extensions.
推荐答案
我发现最好的方法是在基本控制器中使用View :: addExtension;
The best way I have found is to use View::addExtension in your base controller;
这是我的代码示例:
View :: addExtension('blade.html','blade');
View::addExtension('blade.html','blade');
class BaseController extends Controller {
/**
* Setup the layout used by the controller.
*
* @return void
*/
protected function setupLayout()
{
// Allows us to use easy-to-edit html extension files.
// You can set 2nd param to 'php' is you want to
// just process with php (no blade tags)
View::addExtension('blade.html','blade');
if ( ! is_null($this->layout))
{
$this->layout = View::make($this->layout);
}
}
}
这篇关于加载带有.html扩展名的laravel视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!