Methods summary
public static
string|null
|
#
compileTemplate( array<string,array|string|integer> & $context, string $template )
Compile template into PHP code
Compile template into PHP code
Parameters
- $context
- Current context
- $template
- handlebars template
Returns
string|null generated PHP code
|
public static
string
|
#
composePHPRender( array<string,array|string|integer> $context, string $code )
Compose LightnCandy render codes for include()
Compose LightnCandy render codes for include()
Parameters
- $context
- Current context
- $code
- generated PHP code
Returns
string Composed PHP code
|
protected static
string
|
#
getFuncName( array<string,array|string|integer> & $context, string $name, string $tag )
Get function name for standalone or none standalone template.
Get function name for standalone or none standalone template.
Parameters
- $context
- Current context of compiler progress.
- $name
- base function name
- $tag
- original handlabars tag for debug
Returns
string compiled Function name
Expect
'LR::test(' when input array('flags' => array('standalone' => 0, 'debug' => 0), 'runtime' => 'Runtime', 'runtimealias' => 'LR'), 'test', ''
'LL::test2(' when input array('flags' => array('standalone' => 0, 'debug' => 0), 'runtime' => 'Runtime', 'runtimealias' => 'LL'), 'test2', ''
"lala_abctest3(" when input array('flags' => array('standalone' => 1, 'debug' => 0), 'runtime' => 'Runtime', 'runtimealias' => 0, 'funcprefix' => 'lala_abc'), 'test3', ''
'RR::debug(\'abc\', \'test\', ' when input array('flags' => array('standalone' => 0, 'debug' => 1), 'runtime' => 'Runtime', 'runtimealias' => 'RR', 'funcprefix' => 'haha456'), 'test', 'abc'
|
protected static
array<string|array>
|
#
getVariableNames( array<string,array|string|integer> & $context, array<array> $vn, array<string>|null $blockParams = null )
Get string presentation of variables
Get string presentation of variables
Parameters
- $context
- current compile context
- $vn
- variable name array.
- $blockParams
- block param list
Returns
array<string|array> variable names
Expect
array('array(array($in),array())', array('this')) when input array('flags'=>array('spvar'=>true)), array(null)
array('array(array($in,$in),array())', array('this', 'this')) when input array('flags'=>array('spvar'=>true)), array(null, null)
array('array(array(),array(\'a\'=>$in))', array('this')) when input array('flags'=>array('spvar'=>true)), array('a' => null)
|
public static
array<string>
|
#
compileSubExpression( array<string,array|string|integer> & $context, array<boolean|integer|string|array> $vars )
Get string presentation of a sub expression
Get string presentation of a sub expression
Parameters
- $context
- current compile context
- $vars
- parsed arguments list
Returns
array<string> code representing passed expression
|
protected static
array<string>
|
#
getVariableNameOrSubExpression( array<array|string|integer> & $context, array<array|string|integer> $var )
Get string presentation of a subexpression or a variable
Get string presentation of a subexpression or a variable
Parameters
- $context
- current compile context
- $var
- variable parsed path
Returns
array<string> variable names
|
protected static
array<string>
|
#
getVariableName( array<array|string|integer> & $context, array<array|string|integer> $var, array<string>|null $lookup = null, $args = null )
Get string presentation of a variable
Get string presentation of a variable
Parameters
- $context
- $var variable parsed path
- $var
- $context current compile context
- $lookup
- extra lookup string as valid PHP variable name
- $args
Returns
array<string> variable names
Expect
array('$in', 'this') when input array('flags'=>array('spvar'=>true,'debug'=>0)), array(null)
array('(($inary && isset($in[\'true\'])) ? $in[\'true\'] : null)', '[true]') when input array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0,'mustlam'=>0,'lambda'=>0,'jslen'=>0)), array('true')
array('(($inary && isset($in[\'false\'])) ? $in[\'false\'] : null)', '[false]') when input array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0,'mustlam'=>0,'lambda'=>0,'jslen'=>0)), array('false')
array('true', 'true') when input array('flags'=>array('spvar'=>true,'debug'=>0)), array(-1, 'true')
array('false', 'false') when input array('flags'=>array('spvar'=>true,'debug'=>0)), array(-1, 'false')
array('(($inary && isset($in[\'2\'])) ? $in[\'2\'] : null)', '[2]') when input array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0,'mustlam'=>0,'lambda'=>0,'jslen'=>0)), array('2')
array('2', '2') when input array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0)), array(-1, '2')
array('(($inary && isset($in[\'@index\'])) ? $in[\'@index\'] : null)', '[@index]') when input array('flags'=>array('spvar'=>false,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0,'mustlam'=>0,'lambda'=>0,'jslen'=>0)), array('@index')
array("(isset(\$cx['sp_vars']['index']) ? \$cx['sp_vars']['index'] : null)", '@[index]') when input array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0,'mustlam'=>0,'lambda'=>0,'jslen'=>0)), array('@index')
array("(isset(\$cx['sp_vars']['key']) ? \$cx['sp_vars']['key'] : null)", '@[key]') when input array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0,'mustlam'=>0,'lambda'=>0,'jslen'=>0)), array('@key')
array("(isset(\$cx['sp_vars']['first']) ? \$cx['sp_vars']['first'] : null)", '@[first]') when input array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0,'mustlam'=>0,'lambda'=>0,'jslen'=>0)), array('@first')
array("(isset(\$cx['sp_vars']['last']) ? \$cx['sp_vars']['last'] : null)", '@[last]') when input array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0,'mustlam'=>0,'lambda'=>0,'jslen'=>0)), array('@last')
array('(($inary && isset($in[\'"a"\'])) ? $in[\'"a"\'] : null)', '["a"]') when input array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0,'mustlam'=>0,'lambda'=>0,'jslen'=>0)), array('"a"')
array('"a"', '"a"') when input array('flags'=>array('spvar'=>true,'debug'=>0)), array(-1, '"a"')
array('(($inary && isset($in[\'a\'])) ? $in[\'a\'] : null)', '[a]') when input array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0,'mustlam'=>0,'lambda'=>0,'jslen'=>0)), array('a')
array('((isset($cx[\'scopes\'][count($cx[\'scopes\'])-1]) && is_array($cx[\'scopes\'][count($cx[\'scopes\'])-1]) && isset($cx[\'scopes\'][count($cx[\'scopes\'])-1][\'a\'])) ? $cx[\'scopes\'][count($cx[\'scopes\'])-1][\'a\'] : null)', '../[a]') when input array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0,'mustlam'=>0,'lambda'=>0,'jslen'=>0)), array(1,'a')
array('((isset($cx[\'scopes\'][count($cx[\'scopes\'])-3]) && is_array($cx[\'scopes\'][count($cx[\'scopes\'])-3]) && isset($cx[\'scopes\'][count($cx[\'scopes\'])-3][\'a\'])) ? $cx[\'scopes\'][count($cx[\'scopes\'])-3][\'a\'] : null)', '../../../[a]') when input array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0,'mustlam'=>0,'lambda'=>0,'jslen'=>0)), array(3,'a')
array('(($inary && isset($in[\'id\'])) ? $in[\'id\'] : null)', 'this.[id]') when input array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0,'mustlok'=>0,'mustlam'=>0,'lambda'=>0,'jslen'=>0)), array(null, 'id')
array('LR::v($cx, $in, isset($in) ? $in : null, array(\'id\'))', 'this.[id]') when input array('flags'=>array('prop'=>true,'spvar'=>true,'debug'=>0,'method'=>0,'mustlok'=>0,'mustlam'=>0,'lambda'=>0,'jslen'=>0,'standalone'=>0), 'runtime' => 'Runtime', 'runtimealias' => 'LR'), array(null, 'id')
|
protected static
string
|
#
compileToken( array<string,array|string|integer> & $context, array<string,array|boolean> $info )
Return compiled PHP code for a handlebars token
Return compiled PHP code for a handlebars token
Parameters
- $context
- current compile context
- $info
- parsed information
Returns
string Return compiled code segment for the token
|
public static
string
|
#
partial( array<string,array|string|integer> & $context, array<boolean|integer|string|array> $vars )
handle partial
Parameters
- $context
- current compile context
- $vars
- parsed arguments list
Returns
string Return compiled code segment for the partial
Overrides
|
public static
string
|
#
inline( array<string,array|string|integer> & $context, array<boolean|integer|string|array> $vars )
handle inline partial
Parameters
- $context
- current compile context
- $vars
- parsed arguments list
Returns
string Return compiled code segment for the partial
Overrides
|
protected static
string
|
#
invertedSection( array<string,array|string|integer> & $context, array<boolean|integer|string|array> $vars )
Return compiled PHP code for a handlebars inverted section begin token
Return compiled PHP code for a handlebars inverted section begin token
Parameters
- $context
- current compile context
- $vars
- parsed arguments list
Returns
string Return compiled code segment for the token
Overrides
|
protected static
string
|
#
blockCustomHelper( array<string,array|string|integer> & $context, array<boolean|integer|string|array> $vars, boolean $inverted = false )
Return compiled PHP code for a handlebars block custom helper begin token
Return compiled PHP code for a handlebars block custom helper begin token
Parameters
- $context
- current compile context
- $vars
- parsed arguments list
- $inverted
- the logic will be inverted
Returns
string Return compiled code segment for the token
Overrides
|
protected static
string
|
#
blockEnd( array<string,array|string|integer> & $context, array<boolean|integer|string|array> & $vars, string|null $matchop = null )
Return compiled PHP code for a handlebars block end token
Return compiled PHP code for a handlebars block end token
Parameters
- $context
- current compile context
- $vars
- parsed arguments list
- $matchop
- should also match to this operator
Returns
string Return compiled code segment for the token
Overrides
|
protected static
string
|
#
blockBegin( array<string,array|string|integer> & $context, array<boolean|integer|string|array> $vars )
Return compiled PHP code for a handlebars block begin token
Return compiled PHP code for a handlebars block begin token
Parameters
- $context
- current compile context
- $vars
- parsed arguments list
Returns
string Return compiled code segment for the token
Overrides
|
protected static
string|null
|
#
section( array<string,array|string|integer> & $context, array<boolean|integer|string|array> $vars, boolean $isEach = false )
compile {{#foo}} token
Parameters
- $context
- current compile context
- $vars
- parsed arguments list
- $isEach
- the section is #each
Returns
string|null Return compiled code segment for the token
Overrides
|
protected static
string|null
|
#
with( array<string,array|string|integer> & $context, array<boolean|integer|string|array> $vars )
compile {{with}} token
Parameters
- $context
- current compile context
- $vars
- parsed arguments list
Returns
string|null Return compiled code segment for the token
Overrides
|
protected static
string|null
|
#
customHelper( array<string,array|string|integer> & $context, array<boolean|integer|string|array> $vars, boolean $raw, boolean $nosep, boolean $subExp = false )
Return compiled PHP code for a handlebars custom helper token
Return compiled PHP code for a handlebars custom helper token
Parameters
- $context
- current compile context
- $vars
- parsed arguments list
- $raw
- is this {{{ token or not
- $nosep
- true to compile without seperator
- $subExp
- true when compile for subexpression
Returns
string|null Return compiled code segment for the token when the token is custom helper
|
protected static
string
|
#
doElse( array<string,array|string|integer> & $context, array<boolean|integer|string|array> $vars )
Return compiled PHP code for a handlebars else token
Return compiled PHP code for a handlebars else token
Parameters
- $context
- current compile context
- $vars
- parsed arguments list
Returns
string Return compiled code segment for the token when the token is else
Overrides
|
protected static
string
|
#
compileLog( array<string,array|string|integer> & $context, array<boolean|integer|string|array> & $vars, boolean $raw )
Return compiled PHP code for a handlebars log token
Return compiled PHP code for a handlebars log token
Parameters
- $context
- current compile context
- $vars
- parsed arguments list
- $raw
- is this {{{ token or not
Returns
string Return compiled code segment for the token
|
protected static
string
|
#
compileLookup( array<string,array|string|integer> & $context, array<boolean|integer|string|array> & $vars, boolean $raw, boolean $nosep = false )
Return compiled PHP code for a handlebars lookup token
Return compiled PHP code for a handlebars lookup token
Parameters
- $context
- current compile context
- $vars
- parsed arguments list
- $raw
- is this {{{ token or not
- $nosep
- true to compile without seperator
Returns
string Return compiled code segment for the token
|
protected static
string
|
#
compileOutput( array<string,array|string|integer> & $context, string $variable, string $expression, boolean $raw, boolean $nosep )
Return compiled PHP code for template output
Return compiled PHP code for template output
Parameters
- $context
- current compile context
- $variable
- PHP code for the variable
- $expression
- normalized handlebars expression
- $raw
- is this {{{ token or not
- $nosep
- true to compile without seperator
Returns
string Return compiled code segment for the token
|
protected static
string
|
#
compileVariable( array<string,array|string|integer> & $context, array<boolean|integer|string|array> & $vars, boolean $raw, boolean $nosep )
Return compiled PHP code for a handlebars variable token
Return compiled PHP code for a handlebars variable token
Parameters
- $context
- current compile context
- $vars
- parsed arguments list
- $raw
- is this {{{ token or not
- $nosep
- true to compile without seperator
Returns
string Return compiled code segment for the token
|
protected static
|
#
addUsageCount( array<string,array|string|integer> & $context, string $category, string $name, integer $count = 1 )
Add usage count to context
Add usage count to context
Parameters
- $context
- current context
- $category
- category name, can be one of: 'var', 'helpers', 'runtime'
- $name
- used name
- $count
- increment
Expect
1 when input array('usedCount' => array('test' => array())), 'test', 'testname'
3 when input array('usedCount' => array('test' => array('testname' => 2))), 'test', 'testname'
5 when input array('usedCount' => array('test' => array('testname' => 2))), 'test', 'testname', 3
|