Wahyu Kodar
Wahyu Kodar

Reputation: 674

How to pass variable to @extends blade

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.

Upvotes: 8

Views: 17247

Answers (2)

Lal chand
Lal chand

Reputation: 11

Use this:

@extends($template)

instead of:

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

Upvotes: 1

Sid
Sid

Reputation: 5833

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])

Upvotes: 19

Related Questions