Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Blade @include .html files

Include HTML files with blade

Can I include a .html file in stead of .php with Laravel 4 Blade?

My code:

@include('emails.templates.file')
  //file is email.html

file is automatically a .php file..

like image 729
Dirk Jan Avatar asked Oct 15 '14 07:10

Dirk Jan


2 Answers

While @PHPWeblineindia's solution worked for you, it's not really the Laravel way.

However, you can do what you want by telling Laravel's view system to also consider .html files. By default it looks for .blade.php files, and then falls back to .php files. You can add .html to the searched extensions by adding the following somewhere in your bootstrapping code:

// tells the view finder to look for `.html` files and run
// them through the normal PHP `include` process
View::addExtension('html', 'php');

This will actually put HTML as the highest priority, so make sure you don't have two different views called the same thing with different extensions.

like image 118
alexrussell Avatar answered Oct 01 '22 23:10

alexrussell


If its an external file then can you please try this:

<?php include app_path() . '/views/<path_to_layout/emails>/file.html'; ?>

Let me know if its still an issue.

like image 34
PHP Team Avatar answered Oct 02 '22 00:10

PHP Team