8

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.

4
  • you mean you want to pass the value for $template to your master layout? and from where you are getting the value of $template? Commented Sep 21, 2015 at 15:15
  • 1
    I'm done like this: @extends($template) Commented Sep 23, 2015 at 3:34
  • @extends($template) works in laravel 5.2. Commented Oct 15, 2016 at 7:02
  • Possible duplicate: How do I pass a variable to the layout using Laravel' Blade templating? Commented Jan 5, 2022 at 15:09

2 Answers 2

19

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])
Sign up to request clarification or add additional context in comments.

1 Comment

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.
1

Use this:

@extends($template)

instead of:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.