class Template extends PHP

Mako template view renderer.

Traits

Escaper trait.

Properties

protected array $htmlNamedEntityMap HTML entity map. from EscaperTrait
protected FileSystem $fileSystem File system instance.
protected string $cachePath Cache path.
protected array $blocks Template blocks.
protected array $openBlocks Open template blocks.

Methods

string
escapeHTML(string|null $string, string $charset, bool $doubleEncode = true)

Returns a string that has been escaped for a HTML body context.

string
escapeURL(string|null $string)

Returns a string that has been escaped for a URI or parameter context.

string
attributeEscaper(array $matches)

Escapes characters for use in a HTML attribute context.

string
escapeAttribute(string|null $string, string $charset)

Returns a string that has been escaped for a HTML attribute context.

string
cssEscaper(array $matches)

Escapes characters for use in a CSS context.

string
escapeCSS(string|null $string, string $charset)

Returns a string that has been escaped for a CSS context.

string
javascriptEscaper(array $matches)

Escapes characters for use in a Javascript context.

string
escapeJavascript(string|null $string, string $charset)

Returns a string that has been escaped for a Javascript context.

string
render(string $__view__, array $__variables__)

Returns the rendered view.

__construct(FileSystem $fileSystem, string $cachePath)

Constructor.

string
getCompiledPath(string $view)

Returns the path to the compiled template.

bool
needToCompile(string $view, string $compiled)

Returns TRUE if the template needs to be compiled and FALSE if not.

compile(string $view)

Compiles view.

open(string $name)

Opens a template block.

string
close()

Closes a template block.

output(string $name)

Output a template block.

Details

in EscaperTrait at line 53
string escapeHTML(string|null $string, string $charset, bool $doubleEncode = true)

Returns a string that has been escaped for a HTML body context.

Parameters

string|null $string String to escape
string $charset Character set
bool $doubleEncode Should existing entities be encoded?

Return Value

string

in EscaperTrait at line 64
string escapeURL(string|null $string)

Returns a string that has been escaped for a URI or parameter context.

Parameters

string|null $string String to escape

Return Value

string

in EscaperTrait at line 77
protected string attributeEscaper(array $matches)

Escapes characters for use in a HTML attribute context.

(This method contains code from the SecurityMultiTool library).

Parameters

array $matches Regex matches

Return Value

string

in EscaperTrait at line 126
string escapeAttribute(string|null $string, string $charset)

Returns a string that has been escaped for a HTML attribute context.

Parameters

string|null $string String to escape
string $charset Character set

Return Value

string

in EscaperTrait at line 151
protected string cssEscaper(array $matches)

Escapes characters for use in a CSS context.

(This method contains code from the SecurityMultiTool library).

Parameters

array $matches Regex matches

Return Value

string

in EscaperTrait at line 176
string escapeCSS(string|null $string, string $charset)

Returns a string that has been escaped for a CSS context.

Parameters

string|null $string String to escape
string $charset Character set

Return Value

string

in EscaperTrait at line 206
protected string javascriptEscaper(array $matches)

Escapes characters for use in a Javascript context.

(This method contains code from the SecurityMultiTool library).

Parameters

array $matches Regex matches

Return Value

string

in EscaperTrait at line 227
string escapeJavascript(string|null $string, string $charset)

Returns a string that has been escaped for a Javascript context.

Parameters

string|null $string String to escape
string $charset Character set

Return Value

string

at line 145
string render(string $__view__, array $__variables__)

Returns the rendered view.

Parameters

string $__view__ View path
array $__variables__ View variables

Return Value

string

at line 62
__construct(FileSystem $fileSystem, string $cachePath)

Constructor.

Parameters

FileSystem $fileSystem File system instance
string $cachePath Cache path

at line 74
protected string getCompiledPath(string $view)

Returns the path to the compiled template.

Parameters

string $view

Return Value

string

at line 86
protected bool needToCompile(string $view, string $compiled)

Returns TRUE if the template needs to be compiled and FALSE if not.

Parameters

string $view View path
string $compiled Compiled view path

Return Value

bool

at line 96
protected compile(string $view)

Compiles view.

Parameters

string $view View path

at line 106
open(string $name)

Opens a template block.

Parameters

string $name Block name

at line 116
string close()

Closes a template block.

Return Value

string

at line 126
output(string $name)

Output a template block.

Parameters

string $name Block name