6

I have variable {{$template}}.. How can I do for including that variable to @extends. I had try like this:

@extends({{$template}}) // getting error

I hope, there is one answer to help me. Thanks.

Wahyu Kodar
  • 654
  • 1
  • 6
  • 15
  • you mean you want to pass the value for `$template` to your master layout? and from where you are getting the value of `$template`? – Sid Sep 21 '15 at 15:15
  • 1
    I'm done like this: @extends($template) – Wahyu Kodar Sep 23 '15 at 03:34
  • @extends($template) works in laravel 5.2. – Srisa Oct 15 '16 at 07:02
  • **Possible duplicate:** [How do I pass a variable to the layout using Laravel' Blade templating?](https://stackoverflow.com/questions/16118104/how-do-i-pass-a-variable-to-the-layout-using-laravel-blade-templating) – Top-Master Jan 05 '22 at 15:09

2 Answers2

17

you mean you want to pass the value for $template to your layout? and from where you are getting the value of $template?

If you want to pass the variable to layout, then try doing

@extends('<<your layout name>>', ['template' => $template])
Sid
  • 5,693
  • 3
  • 33
  • 50
  • So what a child template extends, can be dynamically set. That's handy to know that a child template is not "locked" onto a specific master template that it extends. – Jason Aug 22 '17 at 16:41
1

Use this:

@extends($template)

instead of:

@extends({{$template}}) // getting error
Obsidian
  • 3,719
  • 8
  • 17
  • 30
Lal chand
  • 11
  • 1