How to pass variable to @extends blade
Asked Answered
V

2

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.

Valve answered 21/9, 2015 at 10:9 Comment(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?Metatherian
I'm done like this: @extends($template)Valve
@extends($template) works in laravel 5.2.Ahimsa
Possible duplicate: How do I pass a variable to the layout using Laravel' Blade templating?Decelerate
M
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])
Metatherian answered 21/9, 2015 at 15:18 Comment(1)
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.Witha
I
1

Use this:

@extends($template)

instead of:

@extends({{$template}}) // getting error
Intercession answered 9/10, 2020 at 18:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.