I think you can refer to some directives such as @include
and @extends
in the laravel blade.
For example, in the admin.common.header
view (located at admin/common/header.blade.php), we have some basic page code (common to various pages such as navigation bar or layout). We use @yield
such as @yield ("extra_js")
or @yield ("extra_css")
where we want to add code later.
header.blade.php
<html>
<head>
something maybe ...
@yield("extra_css")
</head>
<body>
something maybe ...
@yield("extra_js")
</body>
</html>
And in another view such as admin.feedback.feedback
, you can use @extends('admin.common.header')
at the top of the code to inheritance the template and you will get the layout of this template.
For different content in the feedback template, you can use @section
to give you code to fill in the inheritance template such as @section('extra_js')
.
feedback.blade.php
@extends('admin.common.header')
@section('extra_js')
<script> something... </script>
@endsection
If you want to include one blade, just use @include
.
<div>
@include('shared.errors')
<form>
<!-- Form Contents -->
</form>
</div>
In laravel blade there are many instructions to complete the rendering of the template, if you want to know clearly, please refer to the corresponding version of the official document.