In Yii, we can enclose content into a decorator. The common usage of decorators is layout. When you are rendering a view using the render method of your controller, Yii automatically decorates it with the main layout. Let's create a simple decorator that will properly format quotes.
Create a new application using the Composer package manager, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
First, we will create a decorator file,
@app/views/decorators/quote.php
:<div class="quote"> <h2>“<?= $content?>”, <?= $author?></h2> </div>
Now, replace the content of
@app/views/site/index.php
with the following code:<?php use yii\widgets\ContentDecorator; /* @var */ ?> <?php ContentDecorator::begin([ 'viewFile' => '@app/views/decorators/quote.php', 'view' => $this, 'params' => ['author' => 'S. Freud...