1 | <?php |
||
31 | class LightnCandy extends Flags |
||
32 | { |
||
33 | protected static $lastContext; |
||
34 | public static $lastParsed; |
||
35 | |||
36 | /** |
||
37 | * Compile handlebars template into PHP code. |
||
38 | * |
||
39 | * @param string $template handlebars template string |
||
40 | * @param array<string,array|string|integer> $options LightnCandy compile time and run time options, default is array('flags' => LightnCandy::FLAG_BESTPERFORMANCE) |
||
41 | * |
||
42 | * @return string|false Compiled PHP code when successed. If error happened and compile failed, return false. |
||
43 | */ |
||
44 | 763 | public static function compile($template, $options = array('flags' => self::FLAG_BESTPERFORMANCE)) { |
|
62 | |||
63 | /** |
||
64 | * Compile handlebars partial into PHP function code. |
||
65 | * |
||
66 | * @param string $template handlebars template string |
||
67 | * @param array<string,array|string|integer> $options LightnCandy compile time and run time options, default is array('flags' => LightnCandy::FLAG_BESTPERFORMANCE) |
||
68 | * |
||
69 | * @return string|false Compiled PHP code when successed. If error happened and compile failed, return false. |
||
70 | * |
||
71 | * @expect false when input '{{"}}', array('flags' => LightnCandy::FLAG_HANDLEBARS) |
||
72 | */ |
||
73 | 1 | public static function compilePartial($template, $options = array('flags' => self::FLAG_BESTPERFORMANCE)) { |
|
90 | |||
91 | /** |
||
92 | * Handle exists error and return error status. |
||
93 | * |
||
94 | * @param array<string,array|string|integer> $context Current context of compiler progress. |
||
95 | * |
||
96 | * @throws \Exception |
||
97 | * @return boolean True when error detected |
||
98 | * |
||
99 | * @expect false when input array('error' => array()) |
||
100 | * @expect true when input array('error' => array('some error'), 'flags' => array('errorlog' => 0, 'exception' => 0)) |
||
101 | */ |
||
102 | 764 | protected static function handleError(&$context) { |
|
116 | |||
117 | /** |
||
118 | * Get last compiler context. |
||
119 | * |
||
120 | * @return array<string,array|string|integer> Context data |
||
121 | */ |
||
122 | 258 | public static function getContext() { |
|
125 | |||
126 | /** |
||
127 | * 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. |
||
128 | * |
||
129 | * @param string $php PHP code |
||
130 | * @param string|null $tmpDir Optional, change temp directory for php include file saved by prepare() when cannot include PHP code with data:// format. |
||
131 | * @param boolean $delete Optional, delete temp php file when set to tru. Default is true, set it to false for debug propose |
||
132 | * |
||
133 | * @return Closure|false result of include() |
||
134 | * |
||
135 | * @deprecated |
||
136 | */ |
||
137 | 653 | public static function prepare($php, $tmpDir = null, $delete = true) { |
|
168 | } |
||
169 | |||
170 |