Documentation

Compiler extends Validator
in package

LightnCandy Compiler

Table of Contents

$lastParsed  : mixed
compileSubExpression()  : array<string|int, string>
Get string presentation of a sub expression
compileTemplate()  : string|null
Compile template into PHP code
composePHPRender()  : string
Compose LightnCandy render codes for include()
helper()  : bool
Return true when the name is listed in helper table
inline()  : string
handle inline partial
log()  : bool|null
Return true when this is {{log ...}}
lookup()  : bool|null
Return true when this is {{lookup ...}}
partial()  : string
handle partial
resolveHelper()  : bool
use helperresolver to resolve helper, return true when helper founded
verify()  : mixed
Verify template
addUsageCount()  : mixed
Add usage count to context
blockBegin()  : string
Return compiled PHP code for a handlebars block begin token
blockCustomHelper()  : string
Return compiled PHP code for a handlebars block custom helper begin token
blockEnd()  : string
Return compiled PHP code for a handlebars block end token
builtin()  : mixed
validate builtin helpers
comment()  : bool|null
handle comment
compileLog()  : string
Return compiled PHP code for a handlebars log token
compileLookup()  : string
Return compiled PHP code for a handlebars lookup token
compileOutput()  : string
Return compiled PHP code for template output
compileToken()  : string
Return compiled PHP code for a handlebars token
compileVariable()  : string
Return compiled PHP code for a handlebars variable token
customHelper()  : string|null
Return compiled PHP code for a handlebars custom helper token
delimiter()  : bool|null
Verify delimiters and operators
doElse()  : string
Return compiled PHP code for a handlebars else token
doElseChain()  : mixed
handle else chain
doIf()  : bool
validate if token
getFuncName()  : string
Get function name for standalone or none standalone template.
getVariableName()  : array<string|int, string>
Get string presentation of a variable
getVariableNameOrSubExpression()  : array<string|int, string>
Get string presentation of a subexpression or a variable
getVariableNames()  : array<string|int, string|array>
Get string presentation of variables
inlinePartial()  : bool|null
validate inline partial begin token
invertedSection()  : string
Return compiled PHP code for a handlebars inverted section begin token
isBlockHelper()  : bool|null
detect for block custom helper
isDelimiter()  : bool|null
handle delimiter change
operator()  : bool|int|null
Verify operators
partialBlock()  : bool|null
validate partial block token
pushLeft()  : mixed
push left string of current token and clear it
pushPartial()  : mixed
push a string into the partial stacks
pushStack()  : mixed
push current token into the section stack
pushToken()  : mixed
push a token into the stack when it is not empty string
rawblock()  : bool|null
handle raw block
section()  : string|null
compile {{#foo}} token
spacing()  : string|null
Modify $token when spacing rules matched.
token()  : string|array<string, array|string|int>|null
Collect handlebars usage information, detect template error.
unless()  : bool
validate unless token
with()  : string|null
compile {{with}} token

Properties

$lastParsed

public static mixed $lastParsed

Methods

compileSubExpression()

Get string presentation of a sub expression

public static compileSubExpression(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars) : array<string|int, string>
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
array<string|int, string>

code representing passed expression

compileTemplate()

Compile template into PHP code

public static compileTemplate(array<string, array|string|int> &$context, string $template) : string|null
Parameters
$context : array<string, array|string|int>

Current context

$template : string

handlebars template

Return values
string|null

generated PHP code

composePHPRender()

Compose LightnCandy render codes for include()

public static composePHPRender(array<string, array|string|int> $context, string $code) : string
Parameters
$context : array<string, array|string|int>

Current context

$code : string

generated PHP code

Return values
string

Composed PHP code

helper()

Return true when the name is listed in helper table

public static helper(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars[, bool $checkSubexp = false ]) : bool
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

$checkSubexp : bool = false

true when check for subexpression

Return values
bool

Return true when it is custom helper

inline()

handle inline partial

public static inline(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars) : string
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
string

Return compiled code segment for the partial

log()

Return true when this is {{log ...}}

public static log(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars) : bool|null
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
bool|null

Return true when it is custom helper

lookup()

Return true when this is {{lookup ...}}

public static lookup(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars) : bool|null
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
bool|null

Return true when it is custom helper

partial()

handle partial

public static partial(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars) : string
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
string

Return compiled code segment for the partial

resolveHelper()

use helperresolver to resolve helper, return true when helper founded

public static resolveHelper(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> &$vars) : bool
Parameters
$context : array<string, array|string|int>

Current context of compiler progress.

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
bool

$found helper exists or not

verify()

Verify template

public static verify(array<string, array|string|int> &$context, string $template) : mixed
Parameters
$context : array<string, array|string|int>

Current context

$template : string

handlebars template

Return values
mixed

addUsageCount()

Add usage count to context

protected static addUsageCount(array<string, array|string|int> &$context, string $category, string $name[, int $count = 1 ]) : mixed
Parameters
$context : array<string, array|string|int>

current context

$category : string

category name, can be one of: 'var', 'helpers', 'runtime'

$name : string

used name

$count : int = 1

increment

Tags
expect

1 when input array('usedCount' => array('test' => array())), 'test', 'testname'

expect

3 when input array('usedCount' => array('test' => array('testname' => 2))), 'test', 'testname'

expect

5 when input array('usedCount' => array('test' => array('testname' => 2))), 'test', 'testname', 3

Return values
mixed

blockBegin()

Return compiled PHP code for a handlebars block begin token

protected static blockBegin(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars) : string
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
string

Return compiled code segment for the token

blockCustomHelper()

Return compiled PHP code for a handlebars block custom helper begin token

protected static blockCustomHelper(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars[, bool $inverted = false ]) : string
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

$inverted : bool = false

the logic will be inverted

Return values
string

Return compiled code segment for the token

blockEnd()

Return compiled PHP code for a handlebars block end token

protected static blockEnd(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> &$vars[, string|null $matchop = null ]) : string
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

$matchop : string|null = null

should also match to this operator

Return values
string

Return compiled code segment for the token

builtin()

validate builtin helpers

protected static builtin(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars) : mixed
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
mixed

comment()

handle comment

protected static comment(array<string|int, string> &$token, array<string, array|string|int> &$context) : bool|null
Parameters
$token : array<string|int, string>

detected handlebars {{ }} token

$context : array<string, array|string|int>

current compile context

Return values
bool|null

Return true when is comment

compileLog()

Return compiled PHP code for a handlebars log token

protected static compileLog(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> &$vars, bool $raw) : string
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

$raw : bool

is this {{{ token or not

Return values
string

Return compiled code segment for the token

compileLookup()

Return compiled PHP code for a handlebars lookup token

protected static compileLookup(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> &$vars, bool $raw[, bool $nosep = false ]) : string
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

$raw : bool

is this {{{ token or not

$nosep : bool = false

true to compile without seperator

Return values
string

Return compiled code segment for the token

compileOutput()

Return compiled PHP code for template output

protected static compileOutput(array<string, array|string|int> &$context, string $variable, string $expression, bool $raw, bool $nosep) : string
Parameters
$context : array<string, array|string|int>

current compile context

$variable : string

PHP code for the variable

$expression : string

normalized handlebars expression

$raw : bool

is this {{{ token or not

$nosep : bool

true to compile without seperator

Return values
string

Return compiled code segment for the token

compileToken()

Return compiled PHP code for a handlebars token

protected static compileToken(array<string, array|string|int> &$context, array<string, array|bool> $info) : string
Parameters
$context : array<string, array|string|int>

current compile context

$info : array<string, array|bool>

parsed information

Return values
string

Return compiled code segment for the token

compileVariable()

Return compiled PHP code for a handlebars variable token

protected static compileVariable(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> &$vars, bool $raw, bool $nosep) : string
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

$raw : bool

is this {{{ token or not

$nosep : bool

true to compile without seperator

Return values
string

Return compiled code segment for the token

customHelper()

Return compiled PHP code for a handlebars custom helper token

protected static customHelper(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars, bool $raw, bool $nosep[, bool $subExp = false ]) : string|null
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

$raw : bool

is this {{{ token or not

$nosep : bool

true to compile without seperator

$subExp : bool = false

true when compile for subexpression

Return values
string|null

Return compiled code segment for the token when the token is custom helper

delimiter()

Verify delimiters and operators

protected static delimiter(array<string|int, string> $token, array<string, array|string|int> &$context) : bool|null
Parameters
$token : array<string|int, string>

detected handlebars {{ }} token

$context : array<string, array|string|int>

current compile context

Tags
expect

null when input array_fill(0, 11, ''), array()

expect

null when input array(0, 0, 0, 0, 0, '{{', '#', '...', '}}'), array()

expect

true when input array(0, 0, 0, 0, 0, '{', '#', '...', '}'), array()

Return values
bool|null

Return true when invalid

doElse()

Return compiled PHP code for a handlebars else token

protected static doElse(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars) : string
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
string

Return compiled code segment for the token when the token is else

doElseChain()

handle else chain

protected static doElseChain(array<string, array|string|int> &$context) : mixed
Parameters
$context : array<string, array|string|int>

current compile context

Return values
mixed

doIf()

validate if token

protected static doIf(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars) : bool
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
bool

Return true always

getFuncName()

Get function name for standalone or none standalone template.

protected static getFuncName(array<string, array|string|int> &$context, string $name, string $tag) : string
Parameters
$context : array<string, array|string|int>

Current context of compiler progress.

$name : string

base function name

$tag : string

original handlabars tag for debug

Tags
expect

'LR::test(' when input array('flags' => array('standalone' => 0, 'debug' => 0), 'runtime' => 'Runtime', 'runtimealias' => 'LR'), 'test', ''

expect

'LL::test2(' when input array('flags' => array('standalone' => 0, 'debug' => 0), 'runtime' => 'Runtime', 'runtimealias' => 'LL'), 'test2', ''

expect

"lala_abctest3(" when input array('flags' => array('standalone' => 1, 'debug' => 0), 'runtime' => 'Runtime', 'runtimealias' => 0, 'funcprefix' => 'lala_abc'), 'test3', ''

expect

'RR::debug('abc', 'test', ' when input array('flags' => array('standalone' => 0, 'debug' => 1), 'runtime' => 'Runtime', 'runtimealias' => 'RR', 'funcprefix' => 'haha456'), 'test', 'abc'

Return values
string

compiled Function name

getVariableName()

Get string presentation of a variable

protected static getVariableName(array<string|int, array|string|int> &$context, array<string|int, array|string|int> $var[, array<string|int, string>|null $lookup = null ][, mixed $args = null ]) : array<string|int, string>
Parameters
$context : array<string|int, array|string|int>

current compile context

$var : array<string|int, array|string|int>

variable parsed path

$lookup : array<string|int, string>|null = null

extra lookup string as valid PHP variable name

$args : mixed = null
Tags
expect

array('$in', 'this') when input array('flags'=>array('spvar'=>true,'debug'=>0)), array(null)

expect

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')

expect

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')

expect

array('true', 'true') when input array('flags'=>array('spvar'=>true,'debug'=>0)), array(-1, 'true')

expect

array('false', 'false') when input array('flags'=>array('spvar'=>true,'debug'=>0)), array(-1, 'false')

expect

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')

expect

array('2', '2') when input array('flags'=>array('spvar'=>true,'debug'=>0,'prop'=>0,'method'=>0)), array(-1, '2')

expect

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')

expect

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')

expect

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')

expect

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')

expect

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')

expect

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"')

expect

array('"a"', '"a"') when input array('flags'=>array('spvar'=>true,'debug'=>0)), array(-1, '"a"')

expect

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')

expect

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')

expect

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')

expect

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')

expect

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')

Return values
array<string|int, string>

variable names

getVariableNameOrSubExpression()

Get string presentation of a subexpression or a variable

protected static getVariableNameOrSubExpression(array<string|int, array|string|int> &$context, array<string|int, array|string|int> $var) : array<string|int, string>
Parameters
$context : array<string|int, array|string|int>

current compile context

$var : array<string|int, array|string|int>

variable parsed path

Return values
array<string|int, string>

variable names

getVariableNames()

Get string presentation of variables

protected static getVariableNames(array<string, array|string|int> &$context, array<string|int, array<string|int, mixed>> $vn[, array<string|int, string>|null $blockParams = null ]) : array<string|int, string|array>
Parameters
$context : array<string, array|string|int>

current compile context

$vn : array<string|int, array<string|int, mixed>>

variable name array.

$blockParams : array<string|int, string>|null = null

block param list

Tags
expect

array('array(array($in),array())', array('this')) when input array('flags'=>array('spvar'=>true)), array(null)

expect

array('array(array($in,$in),array())', array('this', 'this')) when input array('flags'=>array('spvar'=>true)), array(null, null)

expect

array('array(array(),array('a'=>$in))', array('this')) when input array('flags'=>array('spvar'=>true)), array('a' => null)

Return values
array<string|int, string|array>

variable names

inlinePartial()

validate inline partial begin token

protected static inlinePartial(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars) : bool|null
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
bool|null

Return true when inline partial ends

invertedSection()

Return compiled PHP code for a handlebars inverted section begin token

protected static invertedSection(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars) : string
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
string

Return compiled code segment for the token

isBlockHelper()

detect for block custom helper

protected static isBlockHelper(array<string, array|string|int> $context, array<string|int, bool|int|string|array> $vars) : bool|null
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
bool|null

Return true when this token is block custom helper

isDelimiter()

handle delimiter change

protected static isDelimiter(array<string, array|string|int> &$context) : bool|null
Parameters
$context : array<string, array|string|int>

current compile context

Return values
bool|null

Return true when delimiter changed

operator()

Verify operators

protected static operator(string $operator, array<string, array|string|int> &$context, array<string|int, bool|int|string|array> &$vars) : bool|int|null
Parameters
$operator : string

the operator string

$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Tags
expect

null when input '', array(), array()

expect

2 when input '^', array('usedFeature' => array('isec' => 1), 'level' => 0, 'currentToken' => array(0,0,0,0,0,0,0,0), 'elselvl' => array(), 'flags' => array('spvar' => 0), 'elsechain' => false, 'helperresolver' => 0), array(array('foo'))

expect

true when input '/', array('stack' => array('[with]', '#'), 'level' => 1, 'currentToken' => array(0,0,0,0,0,0,0,'with'), 'flags' => array('nohbh' => 0)), array(array())

expect

4 when input '#', array('usedFeature' => array('sec' => 3), 'level' => 0, 'currentToken' => array(0,0,0,0,0,0,0,0), 'flags' => array('spvar' => 0), 'elsechain' => false, 'elselvl' => array(), 'helperresolver' => 0), array(array('x'))

expect

5 when input '#', array('usedFeature' => array('if' => 4), 'level' => 0, 'currentToken' => array(0,0,0,0,0,0,0,0), 'flags' => array('spvar' => 0, 'nohbh' => 0), 'elsechain' => false, 'elselvl' => array(), 'helperresolver' => 0), array(array('if'))

expect

6 when input '#', array('usedFeature' => array('with' => 5), 'level' => 0, 'flags' => array('nohbh' => 0, 'runpart' => 0, 'spvar' => 0), 'currentToken' => array(0,0,0,0,0,0,0,0), 'elsechain' => false, 'elselvl' => array(), 'helperresolver' => 0), array(array('with'))

expect

7 when input '#', array('usedFeature' => array('each' => 6), 'level' => 0, 'currentToken' => array(0,0,0,0,0,0,0,0), 'flags' => array('spvar' => 0, 'nohbh' => 0), 'elsechain' => false, 'elselvl' => array(), 'helperresolver' => 0), array(array('each'))

expect

8 when input '#', array('usedFeature' => array('unless' => 7), 'level' => 0, 'currentToken' => array(0,0,0,0,0,0,0,0), 'flags' => array('spvar' => 0, 'nohbh' => 0), 'elsechain' => false, 'elselvl' => array(), 'helperresolver' => 0), array(array('unless'))

expect

9 when input '#', array('helpers' => array('abc' => ''), 'usedFeature' => array('helper' => 8), 'level' => 0, 'currentToken' => array(0,0,0,0,0,0,0,0), 'flags' => array('spvar' => 0), 'elsechain' => false, 'elselvl' => array()), array(array('abc'))

expect

11 when input '#', array('helpers' => array('abc' => ''), 'usedFeature' => array('helper' => 10), 'level' => 0, 'currentToken' => array(0,0,0,0,0,0,0,0), 'flags' => array('spvar' => 0), 'elsechain' => false, 'elselvl' => array()), array(array('abc'))

expect

true when input '>', array('partialresolver' => false, 'usedFeature' => array('partial' => 7), 'level' => 0, 'flags' => array('skippartial' => 0, 'runpart' => 0, 'spvar' => 0), 'currentToken' => array(0,0,0,0,0,0,0,0), 'elsechain' => false, 'elselvl' => array()), array('test')

Return values
bool|int|null

Return true when invalid or detected

partialBlock()

validate partial block token

protected static partialBlock(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars) : bool|null
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
bool|null

Return true when partial block ends

pushLeft()

push left string of current token and clear it

protected static pushLeft(array<string, array|string|int> &$context) : mixed
Parameters
$context : array<string, array|string|int>

Current context

Return values
mixed

pushPartial()

push a string into the partial stacks

protected static pushPartial(array<string, array|string|int> &$context, string $append) : mixed
Parameters
$context : array<string, array|string|int>

Current context

$append : string

a string to be appended int partial stacks

Return values
mixed

pushStack()

push current token into the section stack

protected static pushStack(array<string, array|string|int> &$context, string $operation, array<string|int, bool|int|string|array> $vars) : mixed
Parameters
$context : array<string, array|string|int>

Current context

$operation : string

operation string

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
mixed

pushToken()

push a token into the stack when it is not empty string

protected static pushToken(array<string, array|string|int> &$context, string|array<string|int, mixed> $token) : mixed
Parameters
$context : array<string, array|string|int>

Current context

$token : string|array<string|int, mixed>

a parsed token or a string

Return values
mixed

rawblock()

handle raw block

protected static rawblock(array<string|int, string> &$token, array<string, array|string|int> &$context) : bool|null
Parameters
$token : array<string|int, string>

detected handlebars {{ }} token

$context : array<string, array|string|int>

current compile context

Return values
bool|null

Return true when in rawblock mode

section()

compile {{#foo}} token

protected static section(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars[, bool $isEach = false ]) : string|null
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

$isEach : bool = false

the section is #each

Return values
string|null

Return compiled code segment for the token

spacing()

Modify $token when spacing rules matched.

protected static spacing(array<string|int, string> &$token, array<string, array|string|int> &$context[, bool $nost = false ]) : string|null
Parameters
$token : array<string|int, string>

detected handlebars {{ }} token

$context : array<string, array|string|int>

current compile context

$nost : bool = false

do not do stand alone logic

Return values
string|null

Return compiled code segment for the token

token()

Collect handlebars usage information, detect template error.

protected static token(array<string|int, string> &$token, array<string, array|string|int> &$context) : string|array<string, array|string|int>|null
Parameters
$token : array<string|int, string>

detected handlebars {{ }} token

$context : array<string, array|string|int>

current compile context

Return values
string|array<string, array|string|int>|null

$token string when rawblock; array when valid token require to be compiled, null when skip the token.

unless()

validate unless token

protected static unless(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars) : bool
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
bool

Return true always

with()

compile {{with}} token

protected static with(array<string, array|string|int> &$context, array<string|int, bool|int|string|array> $vars) : string|null
Parameters
$context : array<string, array|string|int>

current compile context

$vars : array<string|int, bool|int|string|array>

parsed arguments list

Return values
string|null

Return compiled code segment for the token

Search results