PHP Class LightnCandy\Runtime

Inheritance: extends Encoder
Show file Open project: zordius/lightncandy

Public Methods

Method Description
debug ( string $v, string $f, array\arraystring | integer> $cx ) Output debug info.
enc ( array\arraystring | integer> $cx, arraystring | integer> | integer | null $var ) : string For {{var}} .
encq ( array\arraystring | integer> $cx, arraystring | integer> | integer | null $var ) : string For {{var}} , do html encode just like handlebars.js .
err ( array\arraystring | integer> $cx, string $err ) Handle error by error_log or throw exception.
hbch ( array\arraystring | integer> $cx, string $ch, arraystring | integer> | integer | null $vars, string $op, boolean $inverted, Closure | null $cb = null, Closure | null $else = null ) : string For custom helpers.
ifvar ( array\arraystring | integer> $cx, arraystring | integer> | integer | null $v, boolean $zero ) : boolean For {{#if}} .
in ( array\arraystring | integer> &$cx, string $p, Closure $code ) For {{#* inlinepartial}} .
isec ( array\arraystring | integer> $cx, arraystring | integer> | integer | null $v ) : boolean For {{^var}} .
lo ( array\arraystring | integer> $cx, string $v ) For {{log}} .
m ( array\arraystring | integer> $cx, arraystring | integer> | integer | null $a, arraystring | integer> | integer | null $b ) : arraystring | integer> | integer Get merged context.
miss ( array\arraystring | integer> $cx, string $v ) Handle missing data error.
p ( array\arraystring | integer> $cx, string $p, arraystring | integer> | integer | null $v, $pid, $sp = '' ) : string For {{> partial}} .
sec ( array\arraystring | integer> $cx, arraystring | integer> | integer | null $v, array | null $bp, arraystring | integer> | integer | null $in, boolean $each, Closure $cb, Closure | null $else = null ) : string For {{#var}} or {{#each}} .
v ( array\arraystring | integer> $cx, array | string | boolean | integer | double | null $in, arraystring | integer> $base, array $path, array | null $args = null ) : null | string Resursive lookup variable and helpers. This is slow and will only be used for instance property or method detection or lambdas.
wi ( array\arraystring | integer> $cx, arraystring | integer> | integer | null $v, array | null $bp, arraystring | integer> | integer | null $in, Closure $cb, Closure | null $else = null ) : string For {{#with}} .

Method Details

debug() public static method

Output debug info.
public static debug ( string $v, string $f, array\arraystring | integer> $cx )
$v string expression
$f string runtime function name
$cx array\arraystring | integer>

enc() public static method

For {{var}} .
public static enc ( array\arraystring | integer> $cx, arraystring | integer> | integer | null $var ) : string
$cx array\arraystring | integer>
$var arraystring | integer> | integer | null
return string The htmlencoded value of the specified variable

encq() public static method

For {{var}} , do html encode just like handlebars.js .
public static encq ( array\arraystring | integer> $cx, arraystring | integer> | integer | null $var ) : string
$cx array\arraystring | integer>
$var arraystring | integer> | integer | null
return string The htmlencoded value of the specified variable

err() public static method

Handle error by error_log or throw exception.
public static err ( array\arraystring | integer> $cx, string $err )
$cx array\arraystring | integer>
$err string error message

hbch() public static method

For custom helpers.
public static hbch ( array\arraystring | integer> $cx, string $ch, arraystring | integer> | integer | null $vars, string $op, boolean $inverted, Closure | null $cb = null, Closure | null $else = null ) : string
$cx array\arraystring | integer>
$ch string the name of custom helper to be executed
$vars arraystring | integer> | integer | null
$op string the name of variable resolver. should be one of: 'raw', 'enc', or 'encq'.
$inverted boolean the logic will be inverted
$cb Closure | null callback function to render child context
$else Closure | null callback function to render child context when {{else}}
return string The rendered string of the token

ifvar() public static method

For {{#if}} .
public static ifvar ( array\arraystring | integer> $cx, arraystring | integer> | integer | null $v, boolean $zero ) : boolean
$cx array\arraystring | integer>
$v arraystring | integer> | integer | null
$zero boolean include zero as true
return boolean Return true when the value is not null nor false.

in() public static method

For {{#* inlinepartial}} .
public static in ( array\arraystring | integer> &$cx, string $p, Closure $code )
$cx array\arraystring | integer>
$p string partial name
$code Closure the compiled partial code

isec() public static method

For {{^var}} .
public static isec ( array\arraystring | integer> $cx, arraystring | integer> | integer | null $v ) : boolean
$cx array\arraystring | integer>
$v arraystring | integer> | integer | null
return boolean Return true when the value is not null nor false.

lo() public static method

For {{log}} .
public static lo ( array\arraystring | integer> $cx, string $v )
$cx array\arraystring | integer>
$v string expression

m() public static method

Get merged context.
public static m ( array\arraystring | integer> $cx, arraystring | integer> | integer | null $a, arraystring | integer> | integer | null $b ) : arraystring | integer> | integer
$cx array\arraystring | integer>
$a arraystring | integer> | integer | null
$b arraystring | integer> | integer | null
return arraystring | integer> | integer

miss() public static method

Handle missing data error.
public static miss ( array\arraystring | integer> $cx, string $v )
$cx array\arraystring | integer>
$v string expression

p() public static method

For {{> partial}} .
public static p ( array\arraystring | integer> $cx, string $p, arraystring | integer> | integer | null $v, $pid, $sp = '' ) : string
$cx array\arraystring | integer>
$p string partial name
$v arraystring | integer> | integer | null
return string The rendered string of the partial

sec() public static method

For {{#var}} or {{#each}} .
public static sec ( array\arraystring | integer> $cx, arraystring | integer> | integer | null $v, array | null $bp, arraystring | integer> | integer | null $in, boolean $each, Closure $cb, Closure | null $else = null ) : string
$cx array\arraystring | integer>
$v arraystring | integer> | integer | null
$bp array | null
$in arraystring | integer> | integer | null
$each boolean true when rendering #each
$cb Closure callback function to render child context
$else Closure | null callback function to render child context when {{else}}
return string The rendered string of the section

v() public static method

Resursive lookup variable and helpers. This is slow and will only be used for instance property or method detection or lambdas.
public static v ( array\arraystring | integer> $cx, array | string | boolean | integer | double | null $in, arraystring | integer> $base, array $path, array | null $args = null ) : null | string
$cx array\arraystring | integer>
$in array | string | boolean | integer | double | null current context
$base arraystring | integer>
$path array
$args array | null extra arguments for lambda
return null | string Return the value or null when not found

wi() public static method

For {{#with}} .
public static wi ( array\arraystring | integer> $cx, arraystring | integer> | integer | null $v, array | null $bp, arraystring | integer> | integer | null $in, Closure $cb, Closure | null $else = null ) : string
$cx array\arraystring | integer>
$v arraystring | integer> | integer | null
$bp array | null
$in arraystring | integer> | integer | null
$cb Closure callback function to render child context
$else Closure | null callback function to render child context when {{else}}
return string The rendered string of the token