Documentation

Partial
in package

LightnCandy Partial handler

Table of Contents

$TMP_JS_FUNCTION_STR  : mixed
compile()  : string
compile a template into a closure function
compileDynamic()  : string|null
compile partial as closure, stored in context
compileStatic()  : string|null
compile a partial to static embed PHP code
handleDynamic()  : mixed
Include all partials when using dynamic partials
read()  : string|null
Read partial file content as string and store in context
resolve()  : string|null
resolve partial, return the partial content
resolver()  : string|null
use partialresolver to resolve partial, return the partial content
prePartial()  : string|null
preprocess partial template before it be stored into context

Properties

$TMP_JS_FUNCTION_STR

public static mixed $TMP_JS_FUNCTION_STR = "!!\aFuNcTiOn\a!!"

Methods

compile()

compile a template into a closure function

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

Current context of compiler progress.

$template : string

template string

$name : string|int

partial name or 0

Return values
string

$code compiled PHP code

compileDynamic()

compile partial as closure, stored in context

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

Current context of compiler progress.

$name : string

partial name

Return values
string|null

$code compiled PHP code when success

compileStatic()

compile a partial to static embed PHP code

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

Current context of compiler progress.

$name : string

partial name

Return values
string|null

$code PHP code string

handleDynamic()

Include all partials when using dynamic partials

public static handleDynamic(mixed &$context) : mixed
Parameters
$context : mixed
Return values
mixed

read()

Read partial file content as string and store in context

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

Current context of compiler progress.

$name : string

partial name

Return values
string|null

$code compiled PHP code when success

resolve()

resolve partial, return the partial content

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

Current context of compiler progress.

$name : string

partial name

Return values
string|null

$content partial content

resolver()

use partialresolver to resolve partial, return the partial content

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

Current context of compiler progress.

$name : string

partial name

Return values
string|null

$content partial content

prePartial()

preprocess partial template before it be stored into context

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

Current context of compiler progress.

$tmpl : string

partial template

$name : string

partial name

Tags
expect

'hey' when input array('prepartial' => false), 'hey', 'haha'

expect

'haha-hoho' when input array('prepartial' => function ($cx, $tmpl, $name) {return "$name-$tmpl";}), 'hoho', 'haha'

Return values
string|null

$content processed partial template

Search results