Documentation

MetaTemplate extends Template
in package

Class MetaTemplate

This class represents a meta template for generating dynamic content.

Table of Contents

Constants

Dummy  = 'dummy'
JS  = 'js'
PHP  = 'php'

Properties

$file  : string
$path  : string
$_file  : string
The path to the template file.

Methods

__construct()  : mixed
Constructor
__get()  : mixed
Magic getter method
Create()  : Template
Static constructor
DispatchEvent()  : object|null
Dispatches an event.
HandleEvent()  : self
Adds an event handler.
Insert()  : string
Runs code in a dummy template.
RemoveHandler()  : self
Removes an event handler.
Render()  : string
Renders the template.
RenderCode()  : mixed
Renders code in the template.
Run()  : string
Runs template based on the current template's directory path.
_convertToJS()  : string
Converts meta-language to JavaScript.
_convertToPhp()  : string
Converts meta-language to PHP.

Constants

Properties

$file read-only

public string $file

The file path of the template.

$path read-only

public string $path

The directory path of the template.

$_file

The path to the template file.

protected string $_file

Methods

__construct()

Constructor

public __construct(string $file) : mixed

Initializes a new instance of the MetaTemplate class.

Parameters
$file : string

The template file.

__get()

Magic getter method

public __get(string $prop) : mixed

Retrieves the value of a property.

Parameters
$prop : string

The property name.

Tags
throws
AppException

If the property is unknown.

Return values
mixed

The value of the property.

Create()

Static constructor

public static Create(mixed $file) : Template

Creates a new instance of the Template class.

Parameters
$file : mixed

The template file.

Return values
Template

The created template instance.

DispatchEvent()

Dispatches an event.

public DispatchEvent(string|Event $event[, mixed $args = null ][, bool $async = false ]) : object|null
Parameters
$event : string|Event

The event object or its name.

$args : mixed = null

Additional arguments to pass to the event handlers.

$async : bool = false

Whether to dispatch the event asynchronously.

Return values
object|null

The event object with updated arguments, or null if the event does not exist.

HandleEvent()

Adds an event handler.

public HandleEvent(array<string|int, mixed>|string $ename, mixed $listener) : self
Parameters
$ename : array<string|int, mixed>|string

The event name or an array of event names.

$listener : mixed

The event handler.

Return values
self

Insert()

Runs code in a dummy template.

public Insert(string $file[, mixed $args = [] ]) : string
Parameters
$file : string
$args : mixed = []

The arguments for the code.

Return values
string

The rendered output.

RemoveHandler()

Removes an event handler.

public RemoveHandler(string $ename, mixed $listener) : self
Parameters
$ename : string

The event name.

$listener : mixed

The event handler to remove.

Return values
self

Render()

Renders the template.

public Render([mixed $args = null ]) : string
Parameters
$args : mixed = null

Additional arguments for rendering.

Return values
string

The rendered output.

RenderCode()

Renders code in the template.

public RenderCode(string $code, mixed $args) : mixed
Parameters
$code : string

The code to render.

$args : mixed

The arguments for the code.

Return values
mixed

The rendered output.

Run()

Runs template based on the current template's directory path.

public static Run(string $code, mixed $args) : string
Parameters
$code : string
$args : mixed

Additional arguments for rendering.

Return values
string

The rendered output.

_convertToJS()

Converts meta-language to JavaScript.

private _convertToJS(string $code) : string
Parameters
$code : string

The meta-language code.

Return values
string

The converted JavaScript code.

_convertToPhp()

Converts meta-language to PHP.

private _convertToPhp(string $code) : string
Parameters
$code : string

The meta-language code.

Return values
string

The converted PHP code.


        
On this page

Search results