如何在另一个文件中包含 blade 模板?

How to include blade tempate in another file?

我有两个字段:

landing.blade.php

并阻止 comments.blade.php

如何在 landing.blade.php 中包含 comments.blade.php?

According to the documentation 你需要 @include 它:

landing.blade.php:

<div>
    Some content

    @include('comments', ['comments' => $comments])
</div>

您可以通过以下语法将一个 blade 模板包含到另一个模板中:

包括Sub-Views

@include('view.name')

您还可以将数据数组传递给包含的视图:

@include('view.name', array('some'=>'data'))

更多详情可以关注:

https://laravel.com/docs/5.0/templates

谢谢

简单的方法,

如果 landing.blade.phpcomments.blade.php 在同一个目录中,我们假设它们都在 ressource/view

所以在 landing.blade.php 你可以写 @include('comments')