Blade 中包含HTML文件
我可以在Laravel 4 Blade中包括.html
文件而不是.php
吗?
我的代码:
@include('emails.templates.file')
//file is email.html
file
自动是一个.php
文件。
最佳答案
虽然@PHPWeblineindia的解决方案为您工作,但实际上不是Laravel方式。
但是,您可以通过告诉Laravel的 View 系统也考虑.html
文件来执行所需的操作。默认情况下,它会查找.blade.php
文件,然后回退到.php
文件。您可以通过在引导代码中的以下位置添加.html
到搜索到的扩展名中:
// tells the view finder to look for `.html` files and run
// them through the normal PHP `include` process
View::addExtension('html', 'php');
实际上,这将把HTML置于最高优先级,因此请确保您没有两个具有不同扩展名的称为同一个东西的不同 View 。
关于html - Laravel Blade @include .html文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26377352/