1 | <?php |
||
25 | class Encoder |
||
26 | { |
||
27 | /** |
||
28 | * Get string value |
||
29 | * |
||
30 | * @param array<string,array|string|integer> $cx render time context |
||
31 | * @param array<array|string|integer>|string|integer|null $v value to be output |
||
32 | * @param integer $ex 1 to return untouched value, default is 0 |
||
33 | * |
||
34 | * @return array<array|string|integer>|string|integer|null The raw value of the specified variable |
||
35 | * |
||
36 | * @expect true when input array('flags' => array('jstrue' => 0, 'mustlam' => 0, 'lambda' => 0)), true |
||
37 | * @expect 'true' when input array('flags' => array('jstrue' => 1)), true |
||
38 | * @expect '' when input array('flags' => array('jstrue' => 0, 'mustlam' => 0, 'lambda' => 0)), false |
||
39 | * @expect 'false' when input array('flags' => array('jstrue' => 1)), false |
||
40 | * @expect false when input array('flags' => array('jstrue' => 1)), false, true |
||
41 | * @expect 'Array' when input array('flags' => array('jstrue' => 1, 'jsobj' => 0)), array('a', 'b') |
||
42 | * @expect 'a,b' when input array('flags' => array('jstrue' => 1, 'jsobj' => 1, 'mustlam' => 0, 'lambda' => 0)), array('a', 'b') |
||
43 | * @expect '[object Object]' when input array('flags' => array('jstrue' => 1, 'jsobj' => 1)), array('a', 'c' => 'b') |
||
44 | * @expect '[object Object]' when input array('flags' => array('jstrue' => 1, 'jsobj' => 1)), array('c' => 'b') |
||
45 | * @expect 'a,true' when input array('flags' => array('jstrue' => 1, 'jsobj' => 1, 'mustlam' => 0, 'lambda' => 0)), array('a', true) |
||
46 | * @expect 'a,1' when input array('flags' => array('jstrue' => 0, 'jsobj' => 1, 'mustlam' => 0, 'lambda' => 0)), array('a',true) |
||
47 | * @expect 'a,' when input array('flags' => array('jstrue' => 0, 'jsobj' => 1, 'mustlam' => 0, 'lambda' => 0)), array('a',false) |
||
48 | * @expect 'a,false' when input array('flags' => array('jstrue' => 1, 'jsobj' => 1, 'mustlam' => 0, 'lambda' => 0)), array('a',false) |
||
49 | */ |
||
50 | 419 | public static function raw($cx, $v, $ex = 0) |
|
86 | |||
87 | /** |
||
88 | * Get html encoded string |
||
89 | * |
||
90 | * @param array<string,array|string|integer> $cx render time context |
||
91 | * @param array<array|string|integer>|string|integer|null $var value to be htmlencoded |
||
92 | * |
||
93 | * @return string The htmlencoded value of the specified variable |
||
94 | * |
||
95 | * @expect 'a' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a' |
||
96 | * @expect 'a&b' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a&b' |
||
97 | * @expect 'a'b' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a\'b' |
||
98 | */ |
||
99 | 1 | public static function enc($cx, $var) |
|
103 | |||
104 | /** |
||
105 | * LightnCandy runtime method for {{var}} , and deal with single quote to same as handlebars.js . |
||
106 | * |
||
107 | * @param array<string,array|string|integer> $cx render time context |
||
108 | * @param array<array|string|integer>|string|integer|null $var value to be htmlencoded |
||
109 | * |
||
110 | * @return string The htmlencoded value of the specified variable |
||
111 | * |
||
112 | * @expect 'a' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a' |
||
113 | * @expect 'a&b' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a&b' |
||
114 | * @expect 'a'b' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), 'a\'b' |
||
115 | * @expect '`a'b' when input array('flags' => array('mustlam' => 0, 'lambda' => 0)), '`a\'b' |
||
116 | */ |
||
117 | 1 | public static function encq($cx, $var) |
|
121 | } |
||
122 |