Phpxforms documentation

SlimPlate
in package

Bare bone templating system for text strings, based on Latte syntax Self-fixing >< conversion by HTML editors (TinyMCE) Support $VARIABLES, "VALUES", IF with one condition, ELSE and That's all Folks!

{if $a->b == 5}OK{else}NO{/if}

Tags
author

DaVee8k

license

Lesser General Public License 2.1 or later; see http://www.gnu.org/licenses/lgpl-2.1.html

version
0.87dev

Table of Contents

Properties

$matchData  : array<int, array<int, string>>
$regexIf  : string
$template  : string

Methods

__construct()  : mixed
SlimPlate constructor
check()  : bool
Check template for errors, throw InvalidArgumentException
render()  : string
Render template with current $data
convertValueCon()  : array<string|int, int|float|string>
Convert found value into correct type
decideIfElse()  : string
Find and decide IF/ELSE
findOperator()  : array<string|int, string>
Finds a comparison function
findValue()  : array<string|int, int|float|string>
Get value from condition
findVar()  : array<string|int, string>
Get variable name from the condition and its value
matchVariables()  : array<int, array<int, string>>
Find all variables {$var} in template
operator()  : bool|null
Compare values by given operator, return null for undefined operator
readValueCon()  : array<string|int, int|float|string>
Return value

Properties

$matchData

protected array<int, array<int, string>> $matchData = null

$regexIf

protected static string $regexIf = '/\\{if((?:(?!\\{if).)*)\\}((?:(?!\\{if).)+)\\{\\/if\\}/iU'

Methods

__construct()

SlimPlate constructor

public __construct(string $template) : mixed
Parameters
$template : string

check()

Check template for errors, throw InvalidArgumentException

public check([array<string|int, mixed> $data = [] ][, bool $strict = false ]) : bool
Parameters
$data : array<string|int, mixed> = []
$strict : bool = false
Tags
throws
InvalidArgumentException
Return values
bool

render()

Render template with current $data

public render([array<string|int, mixed> $data = [] ]) : string
Parameters
$data : array<string|int, mixed> = []
Return values
string

convertValueCon()

Convert found value into correct type

protected convertValueCon(string $val) : array<string|int, int|float|string>
Parameters
$val : string
Return values
array<string|int, int|float|string>

decideIfElse()

Find and decide IF/ELSE

protected decideIfElse(int|bool $state, string $val) : string
Parameters
$state : int|bool
$val : string
Return values
string

findOperator()

Finds a comparison function

protected findOperator(string $val) : array<string|int, string>
Parameters
$val : string
Return values
array<string|int, string>

findValue()

Get value from condition

protected findValue(string $val) : array<string|int, int|float|string>
Parameters
$val : string
Return values
array<string|int, int|float|string>

findVar()

Get variable name from the condition and its value

protected findVar(string $val, array<string|int, mixed> $data) : array<string|int, string>
Parameters
$val : string
$data : array<string|int, mixed>
Tags
throws
InvalidArgumentException
Return values
array<string|int, string>

matchVariables()

Find all variables {$var} in template

protected matchVariables() : array<int, array<int, string>>
Return values
array<int, array<int, string>>

operator()

Compare values by given operator, return null for undefined operator

protected operator(mixed $x, string $operator, mixed $y) : bool|null
Parameters
$x : mixed
$operator : string
$y : mixed
Return values
bool|null

readValueCon()

Return value

protected readValueCon(string $val, string|null $sep) : array<string|int, int|float|string>
Parameters
$val : string
$sep : string|null
Tags
throws
InvalidArgumentException
Return values
array<string|int, int|float|string>

        
On this page

Search results