mini\Template\TemplateContext final class

Documentation

Template context - the $this object available in templates

Provides template inheritance via:

  • $this->extend() - extend a parent layout
  • $this->block() / $this->end() - define blocks
  • $this->show() - output blocks in parent templates

Example usage within templates:

<?php $this->extend('layout.php'); ?>
<?php $this->block('title', 'Home'); ?>
<?php $this->block('content'); ?><p>Hello!</p><?php $this->end(); ?>

Properties (4)

public ?string $layout
public array $blocks
private array $stack
private ?string $defaultLayout

Methods (7)

Set the default layout (called from viewstart processing)

Mark this template as extending a parent layout

Define a block (dual-use: inline or buffered)

End a buffered block started with block()

Output a block in parent templates

Include a template file with $this bound to this context

Check for unclosed blocks after template execution

Source

src/Template/TemplateContext.php:20-124