Documentation

LightnCandy extends Flags
in package

LightnCandy major static class

Table of Contents

FLAG_ADVARNAME  = 512
FLAG_BESTPERFORMANCE  = 16388
FLAG_ECHO  = 16384
FLAG_ELSE  = 16777216
FLAG_ERROR_EXCEPTION  = 2
FLAG_ERROR_LOG  = 1
FLAG_ERROR_SKIPPARTIAL  = 4194304
FLAG_EXTHELPER  = 8192
FLAG_HANDLEBARS  = 159390624
FLAG_HANDLEBARSJS  = 192945080
FLAG_HANDLEBARSJS_FULL  = 429235128
FLAG_HANDLEBARSLAMBDA  = 268435456
FLAG_HBESCAPE  = 256
FLAG_IGNORESTANDALONE  = 1073741824
FLAG_INSTANCE  = 98304
FLAG_JS  = 33554456
FLAG_JSLENGTH  = 33554432
FLAG_JSOBJECT  = 16
FLAG_JSTRUE  = 8
FLAG_KNOWNHELPERSONLY  = 4294967296
FLAG_METHOD  = 65536
FLAG_MUSTACHE  = 8597536856
FLAG_MUSTACHELAMBDA  = 2097152
FLAG_MUSTACHELOOKUP  = 262144
FLAG_MUSTACHESECTION  = 8589934592
FLAG_NAMEDARG  = 2048
FLAG_NOESCAPE  = 67108864
FLAG_NOHBHELPERS  = 64
FLAG_PARENT  = 128
FLAG_PARTIALNEWCONTEXT  = 536870912
FLAG_PREVENTINDENT  = 131072
FLAG_PROPERTY  = 32768
FLAG_RAWBLOCK  = 134217728
FLAG_RENDER_DEBUG  = 524288
FLAG_RUNTIMEPARTIAL  = 1048576
FLAG_SLASH  = 8388608
FLAG_SPVARS  = 4096
FLAG_STANDALONEPHP  = 4
FLAG_STRINGPARAMS  = 2147483648
FLAG_THIS  = 32
$lastParsed  : mixed
$lastContext  : mixed
compile()  : string|false
Compile handlebars template into PHP code.
compilePartial()  : string|false
Compile handlebars partial into PHP function code.
getContext()  : array<string, array|string|int>
Get last compiler context.
prepare()  : Closure|false
Get a working render function by a string of PHP code. This method may requires php setting allow_url_include=1 and allow_url_fopen=1 , or access right to tmp file system.
handleError()  : bool
Handle exists error and return error status.

Constants

FLAG_ADVARNAME

public mixed FLAG_ADVARNAME = 512

FLAG_BESTPERFORMANCE

public mixed FLAG_BESTPERFORMANCE = 16388

FLAG_ECHO

public mixed FLAG_ECHO = 16384

FLAG_ELSE

public mixed FLAG_ELSE = 16777216

FLAG_ERROR_EXCEPTION

public mixed FLAG_ERROR_EXCEPTION = 2

FLAG_ERROR_LOG

public mixed FLAG_ERROR_LOG = 1

FLAG_ERROR_SKIPPARTIAL

public mixed FLAG_ERROR_SKIPPARTIAL = 4194304

FLAG_EXTHELPER

public mixed FLAG_EXTHELPER = 8192

FLAG_HANDLEBARS

public mixed FLAG_HANDLEBARS = 159390624

FLAG_HANDLEBARSJS

public mixed FLAG_HANDLEBARSJS = 192945080

FLAG_HANDLEBARSJS_FULL

public mixed FLAG_HANDLEBARSJS_FULL = 429235128

FLAG_HANDLEBARSLAMBDA

public mixed FLAG_HANDLEBARSLAMBDA = 268435456

FLAG_HBESCAPE

public mixed FLAG_HBESCAPE = 256

FLAG_IGNORESTANDALONE

public mixed FLAG_IGNORESTANDALONE = 1073741824

FLAG_INSTANCE

public mixed FLAG_INSTANCE = 98304

FLAG_JS

public mixed FLAG_JS = 33554456

FLAG_JSLENGTH

public mixed FLAG_JSLENGTH = 33554432

FLAG_JSOBJECT

public mixed FLAG_JSOBJECT = 16

FLAG_JSTRUE

public mixed FLAG_JSTRUE = 8

FLAG_KNOWNHELPERSONLY

public mixed FLAG_KNOWNHELPERSONLY = 4294967296

FLAG_METHOD

public mixed FLAG_METHOD = 65536

FLAG_MUSTACHE

public mixed FLAG_MUSTACHE = 8597536856

FLAG_MUSTACHELAMBDA

public mixed FLAG_MUSTACHELAMBDA = 2097152

FLAG_MUSTACHELOOKUP

public mixed FLAG_MUSTACHELOOKUP = 262144

FLAG_MUSTACHESECTION

public mixed FLAG_MUSTACHESECTION = 8589934592

FLAG_NAMEDARG

public mixed FLAG_NAMEDARG = 2048

FLAG_NOESCAPE

public mixed FLAG_NOESCAPE = 67108864

FLAG_NOHBHELPERS

public mixed FLAG_NOHBHELPERS = 64

FLAG_PARENT

public mixed FLAG_PARENT = 128

FLAG_PARTIALNEWCONTEXT

public mixed FLAG_PARTIALNEWCONTEXT = 536870912

FLAG_PREVENTINDENT

public mixed FLAG_PREVENTINDENT = 131072

FLAG_PROPERTY

public mixed FLAG_PROPERTY = 32768

FLAG_RAWBLOCK

public mixed FLAG_RAWBLOCK = 134217728

FLAG_RENDER_DEBUG

public mixed FLAG_RENDER_DEBUG = 524288

FLAG_RUNTIMEPARTIAL

public mixed FLAG_RUNTIMEPARTIAL = 1048576

FLAG_SLASH

public mixed FLAG_SLASH = 8388608

FLAG_SPVARS

public mixed FLAG_SPVARS = 4096

FLAG_STANDALONEPHP

public mixed FLAG_STANDALONEPHP = 4

FLAG_STRINGPARAMS

public mixed FLAG_STRINGPARAMS = 2147483648

FLAG_THIS

public mixed FLAG_THIS = 32

Properties

Methods

compile()

Compile handlebars template into PHP code.

public static compile(string $template[, array<string, array|string|int> $options = array('flags' => self::FLAG_BESTPERFORMANCE) ]) : string|false
Parameters
$template : string

handlebars template string

$options : array<string, array|string|int> = array('flags' => self::FLAG_BESTPERFORMANCE)

LightnCandy compile time and run time options, default is array('flags' => LightnCandy::FLAG_BESTPERFORMANCE)

Return values
string|false

Compiled PHP code when successed. If error happened and compile failed, return false.

compilePartial()

Compile handlebars partial into PHP function code.

public static compilePartial(string $template[, array<string, array|string|int> $options = array('flags' => self::FLAG_BESTPERFORMANCE) ]) : string|false
Parameters
$template : string

handlebars template string

$options : array<string, array|string|int> = array('flags' => self::FLAG_BESTPERFORMANCE)

LightnCandy compile time and run time options, default is array('flags' => LightnCandy::FLAG_BESTPERFORMANCE)

Tags
expect

false when input '{{"}}', array('flags' => LightnCandy::FLAG_HANDLEBARS)

Return values
string|false

Compiled PHP code when successed. If error happened and compile failed, return false.

getContext()

Get last compiler context.

public static getContext() : array<string, array|string|int>
Return values
array<string, array|string|int>

Context data

prepare()

Get a working render function by a string of PHP code. This method may requires php setting allow_url_include=1 and allow_url_fopen=1 , or access right to tmp file system.

public static prepare(string $php[, string|null $tmpDir = null ][, bool $delete = true ]) : Closure|false
Parameters
$php : string

PHP code

$tmpDir : string|null = null

Optional, change temp directory for php include file saved by prepare() when cannot include PHP code with data:// format.

$delete : bool = true

Optional, delete temp php file when set to tru. Default is true, set it to false for debug propose

Tags
deprecated
Return values
Closure|false

result of include()

handleError()

Handle exists error and return error status.

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

Current context of compiler progress.

Tags
throws
Exception
expect

false when input array('error' => array())

expect

true when input array('error' => array('some error'), 'flags' => array('errorlog' => 0, 'exception' => 0))

Return values
bool

True when error detected

Search results