First version of View package is released. This library provides templates rendering abstraction supporting layout-view-subview hierarchy, custom renderers with PHP-based as default and more. It is used in Yii Framework 3 but is supposed to be usable separately.
PHP templates look like the following:
<?php
declare(strict_types=1);
/**
* @var Yiisoft\View\View $this
* @var App\Blog\Post[] $posts
*/
?>
Posts:
<?php foreach ($posts as $post): ?>
Title: <?= $post->getTitle() . "\n" ?>
Description: <?= $post->getDescription() . "\n\n"?>
<?php endforeach ?>
The view package is divided into two parts:
- General purpose view suitable for any template rendering such as emails, SMS messages etc.
- Web-specific views supporting HTML-specific functionality
As usual, the package has 100% tests coverag and close to 100% type coverage and mutation score.