SafeString
extends Encoder
in package
LightnCandy SafeString class
Table of Contents
- EXTENDED_COMMENT_SEARCH = '/{{!--.*?--}}/s'
- IS_BLOCKPARAM_SEARCH = '/^ +\|(.+)\|$/s'
- IS_SUBEXP_SEARCH = '/^\(.+\)$/s'
- $jsContext : mixed
- $string : mixed
- __construct() : mixed
- Constructor
- __toString() : mixed
- enc() : string
- Get html encoded string
- encq() : string
- LightnCandy runtime method for {{var}} , and deal with single quote to same as handlebars.js .
- escapeTemplate() : string
- Escape template
- raw() : array<string|int, array|string|int>|string|int|null
- Get string value
- stripExtendedComments() : string
- Strip extended comments {{!-- .... --}}
Constants
EXTENDED_COMMENT_SEARCH
public
mixed
EXTENDED_COMMENT_SEARCH
= '/{{!--.*?--}}/s'
IS_BLOCKPARAM_SEARCH
public
mixed
IS_BLOCKPARAM_SEARCH
= '/^ +\|(.+)\|$/s'
IS_SUBEXP_SEARCH
public
mixed
IS_SUBEXP_SEARCH
= '/^\(.+\)$/s'
Properties
$jsContext
public
static mixed
$jsContext
= array('flags' => array('jstrue' => 1, 'jsobj' => 1))
$string
private
mixed
$string
Methods
__construct()
Constructor
public
__construct(string $str[, bool|string $escape = false ]) : mixed
Parameters
- $str : string
-
input string
- $escape : bool|string = false
-
false to not escape, true to escape, 'encq' to escape as handlebars.js
Return values
mixed —__toString()
public
__toString() : mixed
Return values
mixed —enc()
Get html encoded string
public
static enc(array<string, array|string|int> $cx, array<string|int, array|string|int>|string|int|null $var) : string
Parameters
- $cx : array<string, array|string|int>
-
render time context
- $var : array<string|int, array|string|int>|string|int|null
-
value to be htmlencoded
Tags
Return values
string —The htmlencoded value of the specified variable
encq()
LightnCandy runtime method for {{var}} , and deal with single quote to same as handlebars.js .
public
static encq(array<string, array|string|int> $cx, array<string|int, array|string|int>|string|int|null $var) : string
Parameters
- $cx : array<string, array|string|int>
-
render time context
- $var : array<string|int, array|string|int>|string|int|null
-
value to be htmlencoded
Tags
Return values
string —The htmlencoded value of the specified variable
escapeTemplate()
Escape template
public
static escapeTemplate(string $template) : string
Parameters
- $template : string
-
handlebars template string
Tags
Return values
string —Escaped template
raw()
Get string value
public
static raw(array<string, array|string|int> $cx, array<string|int, array|string|int>|string|int|null $v, int $ex) : array<string|int, array|string|int>|string|int|null
Parameters
- $cx : array<string, array|string|int>
-
render time context
- $v : array<string|int, array|string|int>|string|int|null
-
value to be output
- $ex : int
-
1 to return untouched value, default is 0
Tags
Return values
array<string|int, array|string|int>|string|int|null —The raw value of the specified variable
stripExtendedComments()
Strip extended comments {{!-- .... --}}
public
static stripExtendedComments(string $template) : string
Parameters
- $template : string
-
handlebars template string
Tags
Return values
string —Stripped template