Dir*_*Jan 5 html view include laravel blade
我可以包含一个.html文件而不是.phpLaravel 4 Blade吗?
我的代码:
@include('emails.templates.file')
//file is email.html
Run Code Online (Sandbox Code Playgroud)
file自动成为.php文件..
ale*_*ell 17
虽然@ PHPWeblineindia的解决方案适合您,但它并不是真正的Laravel方式.
但是,您可以通过告诉Laravel的视图系统也考虑.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');
Run Code Online (Sandbox Code Playgroud)
这实际上将HTML作为最高优先级,因此请确保您没有两个不同的视图,这些视图使用不同的扩展名称相同.
如果它是一个外部文件,那么您可以尝试以下操作:
<?php include app_path() . '/views/<path_to_layout/emails>/file.html'; ?>
Run Code Online (Sandbox Code Playgroud)
让我知道它是否仍然是一个问题。