Base view model for use with Mustache.

The main purpose of this class is to provide the view model with the App instance, thus giving it access to the various helper methods available in that class. Additionally, it provides an instance of Escaper, allowing you to do context-specific escaping within helpers you define in the view model.
category Phlyty
package Phlyty
subpackage View

 Methods

Retrieve application instance

__app() : \Phlyty\App

Returns

Constructor

__construct(\Phlyty\App $app, null|\Zend\Escaper\Escaper $escaper = null
Receive and set the App instance as a protected property. If an Escaper instance is passed, it will be assigned; otherwise, an Escaper instance will be instantiated and assigned.

Parameters

$escaper

null\Zend\Escaper\Escaper

Retrieve escaper instance

__escaper() : \Zend\Escaper\Escaper

Bind a helper within the view model object's context

bindHelper(string $name, callable $helper) : \Phlyty\View\MustacheViewModel
Allows using '$this' within the helper in order to access public properties and methods. Binds the helper to the public property given by $name.

Parameters

$name

string

$helper

callable

Returns

 Properties

 

$app

$app : \Phlyty\App

Default

 

$escaper

$escaper : \Zend\Escaper\Escaper

Default