Is it possible to have Laravel load view templates with a .html extension?
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.
I need to rebuild the app and make the change completely transparent to the users so I'd like to keep the .html extensions.
The best way I have found is to use View::addExtension in your base controller;
Here's my code sample:
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);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With