I'd like to split my layouts into partials.

I'm creating a default blade layout.

The file is called default.blade.php, and lives in the layout folder.

Also under the layout folder is include. In this dir, I have head.blade.php

I would like to call 'head' from 'default'.

Every one of these fails and returns an error when debug is turned on:

@include('include/head'),  @include('include/head.blade.php'), @include('include/head.blade.php')

I have copied head.blade.php into the same folder as default.blade.php, and still get errors.

有帮助吗?

解决方案

You need to give the full path relative to your view folder. Try doing this :

@include('layout.include.head')

其他提示

Keep in mind that Laravel uses dot notation to organize the templates and their parts.

So, the main.blade.php template in your main /views folder should be included directly:

@include ('main')

A main.blade.php template in a, e.g. /views/layouts folder should be called as:

@include ('layouts.main')

and so on.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top