Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading a laravel view with .html extension

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.

like image 750
Mcg1978 Avatar asked Jan 06 '14 17:01

Mcg1978


1 Answers

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);
        }
    }
}
like image 108
Peter Drinnan Avatar answered Oct 22 '22 05:10

Peter Drinnan