How do I pass a variable to the layout using Laravel' Blade templating?

后端 未结 11 2030
猫巷女王i
猫巷女王i 2021-01-30 03:30

In Laravel 4, my controller uses a Blade layout:

class PagesController extends BaseController {
    protected $layout = \         


        
11条回答
  •  庸人自扰
    2021-01-30 04:27

    class PagesController extends BaseController {
        protected $layout = 'layouts.master';
    
        public function index()
        {
            $this->layout->title = "Home page";
            $this->layout->content = View::make('pages/index');
        }
    }
    

    At the Blade Template file, REMEMBER to use @ in front the variable.

    ...
    {{ $title or '' }}
    ...
    @yield('content')
    ...
    

提交回复
热议问题