Conventional Laravel 4 Blade Templating Engine

I am using L4 with Blade. I would like to be able to conditionally expand the layout. For normal use, I would like to expand the master layout, and for ajax rendering, I would like to expand the ajax template. I am using the following code:

@if ( isset($ajax) ) @extends('layouts.ajax') @else @extends('layouts.master') @endif 

But when the page displays this, it simply prints @extend ('layouts.master').

Does anyone know how to conditionally expand a layout or another?

thank

+1
laravel laravel-4 blade
Jul 03 '13 at 18:15
source share
1 answer

Try the first line :

 @extends('layouts.' . isset($ajax) ? 'ajax' : 'master') 

EDIT

You can also use it as follows:

 @extends(((Request::ajax()) ? 'layouts.ajax' : 'layouts.master')) 
+14
Jul 03 '13 at 18:49
source share



All Articles