TemplateEngine

A template engine uses a specific template and the data in a routing context to render a resource into a buffer.

Concrete implementations exist for several well-known template engines.

deprecated
package

Default

Methods

__construct

__construct() 

Returns true if the template engine caches template files. If false, then template files are freshly loaded each time they are used.

isCachingEnabled() : boolean

Response

boolean

True if template files are cached; otherwise, false.

Render the template. Template engines that support partials/fragments should extract the template base path from the template filename up to the last file separator.

render( $arg0,  $arg1,  $arg2,  $arg3 = null) : void

Some engines support localization, for these engines, there is a predefined key "lang" to specify the language to be used in the localization, the format should follow the standard locale formats e.g.: "en-gb", "pt-br", "en".

param $context [array] the routing context param $templateFileName [string] the template file name to use param $handler [callable] the handler that will be called with a result containing the buffer or a failure. render($context, $templateFileName, $handler)

Render the template

param $context [RoutingContext] the routing context param $templateFileName [string] the template file name to use param $handler [callable] the handler that will be called with a result containing the buffer or a failure. this method is deprecated render($context, $templateFileName, $handler)

Render the template

NOTE if you call method directly (i.e. not using @see \io\vertx\jphp\ext\web\handler\TemplateHandler) make sure that templateFileName is sanitized via param $context [RoutingContext] the routing context param $templateDirectory [string] the template directory to use param $templateFileName [string] the relative template file name to use param $handler [callable] the handler that will be called with a result containing the buffer or a failure. this method is deprecated render($context, $templateDirectory, $templateFileName, $handler)

Arguments

$arg0

RoutingContext | array

$arg1

string

$arg2

callable | string

$arg3

callable