Runtime
extends Encoder
in package
LightnCandy class for compiled PHP runtime.
Table of Contents
- DEBUG_ERROR_EXCEPTION = 2
- DEBUG_ERROR_LOG = 1
- DEBUG_TAGS = 4
- DEBUG_TAGS_ANSI = 12
- DEBUG_TAGS_HTML = 20
- debug() : mixed
- Output debug info.
- enc() : string
- For {{var}} .
- encq() : string
- For {{var}} , do html encode just like handlebars.js .
- err() : mixed
- Handle error by error_log or throw exception.
- exch() : string
- Execute custom helper with prepared options
- hbbch() : string
- For block custom helpers.
- hbch() : mixed
- ifvar() : bool
- For {{#if}} .
- in() : mixed
- For {{#* inlinepartial}} .
- isec() : bool
- For {{^var}} .
- lo() : mixed
- For {{log}} .
- m() : array<string|int, array|string|int>|string|int
- Get merged context.
- miss() : mixed
- Handle missing data error.
- p() : string
- For {{> partial}} .
- raw() : array<string|int, array|string|int>|string|int|null
- Get string value
- sec() : string
- For {{#var}} or {{#each}} .
- v() : null|string
- Resursive lookup variable and helpers. This is slow and will only be used for instance property or method detection or lambdas.
- wi() : string
- For {{#with}} .
Constants
DEBUG_ERROR_EXCEPTION
public
mixed
DEBUG_ERROR_EXCEPTION
= 2
DEBUG_ERROR_LOG
public
mixed
DEBUG_ERROR_LOG
= 1
DEBUG_TAGS
public
mixed
DEBUG_TAGS
= 4
DEBUG_TAGS_ANSI
public
mixed
DEBUG_TAGS_ANSI
= 12
DEBUG_TAGS_HTML
public
mixed
DEBUG_TAGS_HTML
= 20
Methods
debug()
Output debug info.
public
static debug(string $v, string $f, array<string, array|string|int> $cx) : mixed
Parameters
- $v : string
-
expression
- $f : string
-
runtime function name
- $cx : array<string, array|string|int>
-
render time context for lightncandy
Tags
Return values
mixed —enc()
For {{var}} .
public
static enc(array<string, array|string|int> $cx, array<string|int, array|string|int>|string|int|null $var) : string
Parameters
- $cx : array<string, array|string|int>
-
render time context for lightncandy
- $var : array<string|int, array|string|int>|string|int|null
-
value to be htmlencoded
Tags
Return values
string —The htmlencoded value of the specified variable
encq()
For {{var}} , do html encode just like handlebars.js .
public
static encq(array<string, array|string|int> $cx, array<string|int, array|string|int>|string|int|null $var) : string
Parameters
- $cx : array<string, array|string|int>
-
render time context for lightncandy
- $var : array<string|int, array|string|int>|string|int|null
-
value to be htmlencoded
Tags
Return values
string —The htmlencoded value of the specified variable
err()
Handle error by error_log or throw exception.
public
static err(array<string, array|string|int> $cx, string $err) : mixed
Parameters
- $cx : array<string, array|string|int>
-
render time context for lightncandy
- $err : string
-
error message
Tags
Return values
mixed —exch()
Execute custom helper with prepared options
public
static exch(array<string, array|string|int> $cx, string $ch, array<string|int, array|string|int>|string|int|null $vars, array<string, array|string|int> &$options) : string
Parameters
- $cx : array<string, array|string|int>
-
render time context for lightncandy
- $ch : string
-
the name of custom helper to be executed
- $vars : array<string|int, array|string|int>|string|int|null
-
variables for the helper
- $options : array<string, array|string|int>
-
the options object
Return values
string —The rendered string of the token
hbbch()
For block custom helpers.
public
static hbbch(array<string, array|string|int> &$cx, string $ch, array<string|int, array|string|int>|string|int|null $vars, array<string, array|string|int> &$_this, bool $inverted, Closure|null $cb[, Closure|null $else = null ]) : string
Parameters
- $cx : array<string, array|string|int>
-
render time context for lightncandy
- $ch : string
-
the name of custom helper to be executed
- $vars : array<string|int, array|string|int>|string|int|null
-
variables for the helper
- $_this : array<string, array|string|int>
-
current rendering context for the helper
- $inverted : bool
-
the logic will be inverted
- $cb : Closure|null
-
callback function to render child context
- $else : Closure|null = null
-
callback function to render child context when {{else}}
Return values
string —The rendered string of the token
hbch()
public
static hbch(mixed &$cx, mixed $ch, mixed $vars, mixed $op, mixed &$_this) : mixed
Parameters
- $cx : mixed
- $ch : mixed
- $vars : mixed
- $op : mixed
- $_this : mixed
Return values
mixed —ifvar()
For {{#if}} .
public
static ifvar(array<string, array|string|int> $cx, array<string|int, array|string|int>|string|int|null $v, bool $zero) : bool
Parameters
- $cx : array<string, array|string|int>
-
render time context for lightncandy
- $v : array<string|int, array|string|int>|string|int|null
-
value to be tested
- $zero : bool
-
include zero as true
Tags
Return values
bool —Return true when the value is not null nor false.
in()
For {{#* inlinepartial}} .
public
static in(array<string, array|string|int> &$cx, string $p, Closure $code) : mixed
Parameters
- $cx : array<string, array|string|int>
-
render time context for lightncandy
- $p : string
-
partial name
- $code : Closure
-
the compiled partial code
Return values
mixed —isec()
For {{^var}} .
public
static isec(array<string, array|string|int> $cx, array<string|int, array|string|int>|string|int|null $v) : bool
Parameters
- $cx : array<string, array|string|int>
-
render time context for lightncandy
- $v : array<string|int, array|string|int>|string|int|null
-
value to be tested
Tags
Return values
bool —Return true when the value is not null nor false.
lo()
For {{log}} .
public
static lo(array<string, array|string|int> $cx, string $v) : mixed
Parameters
- $cx : array<string, array|string|int>
-
render time context for lightncandy
- $v : string
-
expression
Return values
mixed —m()
Get merged context.
public
static m(array<string, array|string|int> $cx, array<string|int, array|string|int>|string|int|null $a, array<string|int, array|string|int>|string|int|null $b) : array<string|int, array|string|int>|string|int
Parameters
- $cx : array<string, array|string|int>
-
render time context for lightncandy
- $a : array<string|int, array|string|int>|string|int|null
-
the context to be merged
- $b : array<string|int, array|string|int>|string|int|null
-
the new context to overwrite
Return values
array<string|int, array|string|int>|string|int —the merged context object
miss()
Handle missing data error.
public
static miss(array<string, array|string|int> $cx, string $v) : mixed
Parameters
- $cx : array<string, array|string|int>
-
render time context for lightncandy
- $v : string
-
expression
Return values
mixed —p()
For {{> partial}} .
public
static p(array<string, array|string|int> $cx, string $p, array<string|int, array|string|int>|string|int|null $v, mixed $pid[, mixed $sp = '' ]) : string
Parameters
- $cx : array<string, array|string|int>
-
render time context for lightncandy
- $p : string
-
partial name
- $v : array<string|int, array|string|int>|string|int|null
-
value to be the new context
- $pid : mixed
- $sp : mixed = ''
Return values
string —The rendered string of the partial
raw()
Get string value
public
static raw(array<string, array|string|int> $cx, array<string|int, array|string|int>|string|int|null $v, int $ex) : array<string|int, array|string|int>|string|int|null
Parameters
- $cx : array<string, array|string|int>
-
render time context
- $v : array<string|int, array|string|int>|string|int|null
-
value to be output
- $ex : int
-
1 to return untouched value, default is 0
Tags
Return values
array<string|int, array|string|int>|string|int|null —The raw value of the specified variable
sec()
For {{#var}} or {{#each}} .
public
static sec(array<string, array|string|int> $cx, array<string|int, array|string|int>|string|int|null $v, array<string|int, string>|null $bp, array<string|int, array|string|int>|string|int|null $in, bool $each, Closure $cb[, Closure|null $else = null ]) : string
Parameters
- $cx : array<string, array|string|int>
-
render time context for lightncandy
- $v : array<string|int, array|string|int>|string|int|null
-
value for the section
- $bp : array<string|int, string>|null
-
block parameters
- $in : array<string|int, array|string|int>|string|int|null
-
input data with current scope
- $each : bool
-
true when rendering #each
- $cb : Closure
-
callback function to render child context
- $else : Closure|null = null
-
callback function to render child context when {{else}}
Tags
Return values
string —The rendered string of the section
v()
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<string, array|string|int> $cx, array<string|int, mixed>|string|bool|int|float|null $in, array<string|int, array|string|int> $base, array<string|int, string|int> $path[, array<string|int, mixed>|null $args = null ]) : null|string
Parameters
- $cx : array<string, array|string|int>
-
render time context for lightncandy
- $in : array<string|int, mixed>|string|bool|int|float|null
-
current context
- $base : array<string|int, array|string|int>
-
current variable context
- $path : array<string|int, string|int>
-
array of names for path
- $args : array<string|int, mixed>|null = null
-
extra arguments for lambda
Tags
Return values
null|string —Return the value or null when not found
wi()
For {{#with}} .
public
static wi(array<string, array|string|int> $cx, array<string|int, array|string|int>|string|int|null $v, array<string|int, string>|null $bp, array<string|int, array|string|int>|string|int|null $in, Closure $cb[, Closure|null $else = null ]) : string
Parameters
- $cx : array<string, array|string|int>
-
render time context for lightncandy
- $v : array<string|int, array|string|int>|string|int|null
-
value to be the new context
- $bp : array<string|int, string>|null
-
block parameters
- $in : array<string|int, array|string|int>|string|int|null
-
input data with current scope
- $cb : Closure
-
callback function to render child context
- $else : Closure|null = null
-
callback function to render child context when {{else}}
Tags
Return values
string —The rendered string of the token