W
W
windoctor2014-11-25 11:21:07
Laravel
windoctor, 2014-11-25 11:21:07

Laravel. template system?

Greetings.
I decided to tinker with Laravel 4, but didn't figure out how to work with templates.
How it is done in Yii2:
In the layout we write
<?=$content;?>
In the template, what we want to display.
In Laravel4:
In layout we write:
@yield('content')
In the template:

@extends('layouts.default')
@section('content')
Контент
@stop

Is it possible to do this somehow easier? To at least not constantly declare layout.
PS I declared the layout variable in the controller, it did not help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2014-11-25
@windoctor

I think you should do one very useful thing - read the documentation.
In general, this is called "template inheritance". In Yii, a crutch with layouts. That is, unlike Yii, you can have infinite nesting and you can redefine blocks at each level. This allows you to reduce duplication in templates to the maximum. Templates are compiled so there are no performance problems either.

S
Sergey Semenko, 2014-11-25
@abler98

There are only 3 lines, where is it easier? But you can create several sections

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question