mini\render() Function

Documentation

Render a template with provided variables

Supports multi-level template inheritance via $this->extend() and $this->block(). Uses path registry to find templates in _views/ directory.

Simple templates:

echo render('settings.php', ['user' => $user]);

With layout inheritance:

// child.php
<?php $this->extend('layout.php'); ?>
<?php $this->block('title', 'My Page'); ?>
<?php $this->block('content'); ?><p>Content here</p><?php $this->end(); ?>

// layout.php
<html><head><title><?php $this->show('title', 'Untitled'); ?></title></head>
<body><?php $this->show('content'); ?></body></html>

Including sub-templates (partials):

<?= mini\render('user-card.php', ['user' => $currentUser]) ?>

Signature

function render(string $template, array $vars = array (
)): string

Parameters

Name Type Default Description
$template string required Documentation missing
$vars array array ( ) Documentation missing

Returns

string

Source

src/Template/functions.php:60-62