WPZylos Views

Template rendering with context sharing, multi-engine support, and auto-escaping.

What You Get

  • ViewFactory — Render PHP templates with data
  • Deferred rendering — Create View instances to render later
  • Multi-engine — PHP templates and optional Twig adapter
  • Context sharing — Global variables for all views
  • Dot notation — Reference views like admin.settings

Quick Start

use WPZylos\Framework\Views\ViewFactory;

$views = new ViewFactory($context);

// Render template (dot notation)
echo $views->render('admin.dashboard', [
    'title' => 'Dashboard',
    'users' => $users,
]);

Template Example

<!-- resources/views/admin/dashboard.php -->
<?php /** @var string $title */ ?>
<?php /** @var array $users */ ?>

<div class="wrap">
    <h1><?= esc_html($title) ?></h1>

    <table class="wp-list-table widefat">
        <?php foreach ($users as $user): ?>
        <tr>
            <td><?= esc_html($user->name) ?></td>
        </tr>
        <?php endforeach; ?>
    </table>
</div>

Documentation