PHP Class LightnCandy\Compiler

Inheritance: extends Validator
Afficher le fichier Open project: zordius/lightncandy Class Usage Examples

Méthodes publiques

Свойство Type Description
$lastParsed

Méthodes publiques

Méthode Description
compileSubExpression ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : array Get string presentation of a sub expression
compileTemplate ( array\arraystring | integer> &$context, string $template ) : string | null Compile template into PHP code
composePHPRender ( array\arraystring | integer> $context, string $code ) : string Compose LightnCandy render codes for include()
inline ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : string handle inline partial
partial ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : string handle partial

Méthodes protégées

Méthode Description
addUsageCount ( array\arraystring | integer> &$context, string $category, string $name, integer $count = 1 ) Add usage count to context
blockBegin ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : string Return compiled PHP code for a handlebars block begin token
blockCustomHelper ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars, boolean $inverted = false ) : string Return compiled PHP code for a handlebars block custom helper begin token
blockEnd ( array\arraystring | integer> &$context, arrayinteger | string | array> &$vars, string | null $matchop = NULL ) : string Return compiled PHP code for a handlebars block end token
compileLog ( array\arraystring | integer> &$context, arrayinteger | string | array> &$vars, boolean $raw ) : string Return compiled PHP code for a handlebars log token
compileLookup ( array\arraystring | integer> &$context, arrayinteger | string | array> &$vars, boolean $raw, boolean $nosep = false ) : string Return compiled PHP code for a handlebars lookup token
compileOutput ( array\arraystring | integer> &$context, string $variable, string $expression, boolean $raw, boolean $nosep ) : string Return compiled PHP code for template output
compileToken ( array\arraystring | integer> &$context, array\array $info ) : string Return compiled PHP code for a handlebars token
compileVariable ( array\arraystring | integer> &$context, arrayinteger | string | array> &$vars, boolean $raw, boolean $nosep ) : string Return compiled PHP code for a handlebars variable token
customHelper ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars, boolean $raw, boolean $nosep, boolean $subExp = false ) : string | null Return compiled PHP code for a handlebars custom helper token
doElse ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : string Return compiled PHP code for a handlebars else token
getFuncName ( array\arraystring | integer> &$context, string $name, string $tag ) : string Get function name for standalone or none standalone template.
getVariableName ( arraystring | integer> &$context, arraystring | integer> $var, array | null $lookup = null, $args = null ) : array Get string presentation of a variable
getVariableNameOrSubExpression ( arraystring | integer> &$context, arraystring | integer> $var ) : array Get string presentation of a subexpression or a variable
getVariableNames ( array\arraystring | integer> &$context, array $vn, array | null $blockParams = null ) : array Get string presentation of variables
invertedSection ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : string Return compiled PHP code for a handlebars inverted section begin token
section ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars, boolean $isEach = false ) : string | null compile {{#foo}} token
with ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : string | null compile {{with}} token

Method Details

addUsageCount() protected static méthode

Add usage count to context
protected static addUsageCount ( array\arraystring | integer> &$context, string $category, string $name, integer $count = 1 )
$context array\arraystring | integer>
$category string category name, can be one of: 'var', 'helpers', 'runtime'
$name string used name
$count integer increment

blockBegin() protected static méthode

Return compiled PHP code for a handlebars block begin token
protected static blockBegin ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : string
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat string Return compiled code segment for the token

blockCustomHelper() protected static méthode

Return compiled PHP code for a handlebars block custom helper begin token
protected static blockCustomHelper ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars, boolean $inverted = false ) : string
$context array\arraystring | integer>
$vars arrayinteger | string | array>
$inverted boolean the logic will be inverted
Résultat string Return compiled code segment for the token

blockEnd() protected static méthode

Return compiled PHP code for a handlebars block end token
protected static blockEnd ( array\arraystring | integer> &$context, arrayinteger | string | array> &$vars, string | null $matchop = NULL ) : string
$context array\arraystring | integer>
$vars arrayinteger | string | array>
$matchop string | null should also match to this operator
Résultat string Return compiled code segment for the token

compileLog() protected static méthode

Return compiled PHP code for a handlebars log token
protected static compileLog ( array\arraystring | integer> &$context, arrayinteger | string | array> &$vars, boolean $raw ) : string
$context array\arraystring | integer>
$vars arrayinteger | string | array>
$raw boolean is this {{{ token or not
Résultat string Return compiled code segment for the token

compileLookup() protected static méthode

Return compiled PHP code for a handlebars lookup token
protected static compileLookup ( array\arraystring | integer> &$context, arrayinteger | string | array> &$vars, boolean $raw, boolean $nosep = false ) : string
$context array\arraystring | integer>
$vars arrayinteger | string | array>
$raw boolean is this {{{ token or not
$nosep boolean true to compile without seperator
Résultat string Return compiled code segment for the token

compileOutput() protected static méthode

Return compiled PHP code for template output
protected static compileOutput ( array\arraystring | integer> &$context, string $variable, string $expression, boolean $raw, boolean $nosep ) : string
$context array\arraystring | integer>
$variable string PHP code for the variable
$expression string normalized handlebars expression
$raw boolean is this {{{ token or not
$nosep boolean true to compile without seperator
Résultat string Return compiled code segment for the token

compileSubExpression() public static méthode

Get string presentation of a sub expression
public static compileSubExpression ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : array
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat array

compileTemplate() public static méthode

Compile template into PHP code
public static compileTemplate ( array\arraystring | integer> &$context, string $template ) : string | null
$context array\arraystring | integer>
$template string handlebars template
Résultat string | null generated PHP code

compileToken() protected static méthode

Return compiled PHP code for a handlebars token
protected static compileToken ( array\arraystring | integer> &$context, array\array $info ) : string
$context array\arraystring | integer>
$info array\array
Résultat string Return compiled code segment for the token

compileVariable() protected static méthode

Return compiled PHP code for a handlebars variable token
protected static compileVariable ( array\arraystring | integer> &$context, arrayinteger | string | array> &$vars, boolean $raw, boolean $nosep ) : string
$context array\arraystring | integer>
$vars arrayinteger | string | array>
$raw boolean is this {{{ token or not
$nosep boolean true to compile without seperator
Résultat string Return compiled code segment for the token

composePHPRender() public static méthode

Compose LightnCandy render codes for include()
public static composePHPRender ( array\arraystring | integer> $context, string $code ) : string
$context array\arraystring | integer>
$code string generated PHP code
Résultat string Composed PHP code

customHelper() protected static méthode

Return compiled PHP code for a handlebars custom helper token
protected static customHelper ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars, boolean $raw, boolean $nosep, boolean $subExp = false ) : string | null
$context array\arraystring | integer>
$vars arrayinteger | string | array>
$raw boolean is this {{{ token or not
$nosep boolean true to compile without seperator
$subExp boolean true when compile for subexpression
Résultat string | null Return compiled code segment for the token when the token is custom helper

doElse() protected static méthode

Return compiled PHP code for a handlebars else token
protected static doElse ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : string
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat string Return compiled code segment for the token when the token is else

getFuncName() protected static méthode

Get function name for standalone or none standalone template.
protected static getFuncName ( array\arraystring | integer> &$context, string $name, string $tag ) : string
$context array\arraystring | integer>
$name string base function name
$tag string original handlabars tag for debug
Résultat string compiled Function name

getVariableName() protected static méthode

Get string presentation of a variable
protected static getVariableName ( arraystring | integer> &$context, arraystring | integer> $var, array | null $lookup = null, $args = null ) : array
$context arraystring | integer>
$var arraystring | integer>
$lookup array | null
Résultat array

getVariableNameOrSubExpression() protected static méthode

Get string presentation of a subexpression or a variable
protected static getVariableNameOrSubExpression ( arraystring | integer> &$context, arraystring | integer> $var ) : array
$context arraystring | integer>
$var arraystring | integer>
Résultat array

getVariableNames() protected static méthode

Get string presentation of variables
protected static getVariableNames ( array\arraystring | integer> &$context, array $vn, array | null $blockParams = null ) : array
$context array\arraystring | integer>
$vn array
$blockParams array | null
Résultat array

inline() public static méthode

handle inline partial
public static inline ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : string
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat string Return compiled code segment for the partial

invertedSection() protected static méthode

Return compiled PHP code for a handlebars inverted section begin token
protected static invertedSection ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : string
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat string Return compiled code segment for the token

partial() public static méthode

handle partial
public static partial ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : string
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat string Return compiled code segment for the partial

section() protected static méthode

compile {{#foo}} token
protected static section ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars, boolean $isEach = false ) : string | null
$context array\arraystring | integer>
$vars arrayinteger | string | array>
$isEach boolean the section is #each
Résultat string | null Return compiled code segment for the token

with() protected static méthode

compile {{with}} token
protected static with ( array\arraystring | integer> &$context, arrayinteger | string | array> $vars ) : string | null
$context array\arraystring | integer>
$vars arrayinteger | string | array>
Résultat string | null Return compiled code segment for the token

Property Details

$lastParsed public_oe static_oe property

public static $lastParsed