Leaf PHP

TemplateHelper
in package

Exposes useful tools for working with/in templates

Table of Contents

Properties

$applicationRootPath  : string
$cloner  : AbstractCloner
$htmlDumper  : HtmlDumper
$htmlDumperOutput  : HtmlDumperOutput
$variables  : array<string|int, mixed>
An array of variables to be passed to all templates

Methods

__construct()  : mixed
breakOnDelimiter()  : string
Makes sure that the given string breaks on the delimiter.
delVariable()  : mixed
Unsets a single template variable, by its name
dump()  : string
Format the given value into a human readable string.
dumpArgs()  : string
Format the args of the given Frame as a human readable html string
escape()  : string
Escapes a string for output in an HTML document
escapeButPreserveUris()  : string
Escapes a string for output in an HTML document, but preserves URIs within it, and converts them to clickable anchor elements.
getApplicationRootPath()  : string
Return the application root path.
getCloner()  : AbstractCloner
Get the cloner used for dumping variables.
getVariable()  : mixed
Gets a single template variable, by its name, or $defaultValue if the variable does not exist
getVariables()  : array<string|int, mixed>
Returns all variables for this helper
render()  : mixed
Given a template path, render it within its own scope. This method also accepts an array of additional variables to be passed to the template.
setApplicationRootPath()  : mixed
Set the application root path.
setCloner()  : mixed
Set the cloner used for dumping variables.
setVariable()  : mixed
Sets a single template variable, by its name:
setVariables()  : mixed
Sets the variables to be passed to all templates rendered by this template helper.
shorten()  : string
Replace the part of the path that all files have in common.
slug()  : string
Convert a string to a slug version of itself
getDumper()  : mixed

Properties

$variables

An array of variables to be passed to all templates

private array<string|int, mixed> $variables = []

Methods

breakOnDelimiter()

Makes sure that the given string breaks on the delimiter.

public breakOnDelimiter(string $delimiter, string $s) : string
Parameters
$delimiter : string
$s : string
Return values
string

delVariable()

Unsets a single template variable, by its name

public delVariable(string $variableName) : mixed
Parameters
$variableName : string

dump()

Format the given value into a human readable string.

public dump(mixed $value) : string
Parameters
$value : mixed
Return values
string

dumpArgs()

Format the args of the given Frame as a human readable html string

public dumpArgs(Frame $frame) : string
Parameters
$frame : Frame
Return values
string

the rendered html

escape()

Escapes a string for output in an HTML document

public escape(string $raw) : string
Parameters
$raw : string
Return values
string

escapeButPreserveUris()

Escapes a string for output in an HTML document, but preserves URIs within it, and converts them to clickable anchor elements.

public escapeButPreserveUris(string $raw) : string
Parameters
$raw : string
Return values
string

getApplicationRootPath()

Return the application root path.

public getApplicationRootPath() : string
Return values
string

getVariable()

Gets a single template variable, by its name, or $defaultValue if the variable does not exist

public getVariable(string $variableName[, mixed $defaultValue = null ]) : mixed
Parameters
$variableName : string
$defaultValue : mixed = null

getVariables()

Returns all variables for this helper

public getVariables() : array<string|int, mixed>
Return values
array<string|int, mixed>

render()

Given a template path, render it within its own scope. This method also accepts an array of additional variables to be passed to the template.

public render(string $template[, array<string|int, mixed> $additionalVariables = null ]) : mixed
Parameters
$template : string
$additionalVariables : array<string|int, mixed> = null

setApplicationRootPath()

Set the application root path.

public setApplicationRootPath(string $applicationRootPath) : mixed
Parameters
$applicationRootPath : string

setVariable()

Sets a single template variable, by its name:

public setVariable(string $variableName, mixed $variableValue) : mixed
Parameters
$variableName : string
$variableValue : mixed

setVariables()

Sets the variables to be passed to all templates rendered by this template helper.

public setVariables(array<string|int, mixed> $variables) : mixed
Parameters
$variables : array<string|int, mixed>

shorten()

Replace the part of the path that all files have in common.

public shorten(string $path) : string
Parameters
$path : string
Return values
string

slug()

Convert a string to a slug version of itself

public slug(string $original) : string
Parameters
$original : string
Return values
string

        
On this page

Search results