L
L
lemonlimelike2018-10-24 21:36:12
Laravel
lemonlimelike, 2018-10-24 21:36:12

Why doesn't blade Laravel work?

Sorry for such a stupid question, but I'm just at a dead end. I used to work with the blade template engine, everything worked fine, now I decided to remember, and some kind of nonsense turns out.
There is this route:

Route::get('/', function () {
    return view('main.index');
});

Here is the file code main.index:
<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="{{ asset('css/style.css') }}">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <meta charset="utf-8">
</head>
<body>
  @include('components.header')
  <div class="grid">
    <div class="grid__width-1">
      @yield('sidebar')
    </div>
    <div class="grid__width-2">
      @yield('content')
    </div>
  </div>
</body>
</html>

As you can see, I include the header, everything is displayed there, but the yield directives do not display what they should have.
Here is the content of the sidebar file:
@extends('main.index')

@section('sidebar')
  SIDEBAR
@endsection

And the contents of the content file:
@extends('main.index')

@section('content')
  CONTENT
@endsection

Here's the file structure:
5bd0bb8651685926500222.png
Why doesn't the content of the sidebar and content files want to be displayed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
netrox, 2018-10-24
@lemonlimelike

You are calling the parent view instead of the child. Use And
instead of route:yield('sidebar')include()

Route::get('/', function () {
    return view('content');
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question