1 | <?php |
||
30 | class Partial |
||
31 | { |
||
32 | public static $TMP_JS_FUNCTION_STR = "!!\aFuNcTiOn\a!!"; |
||
33 | |||
34 | /** |
||
35 | * Include all partials when using dynamic partials |
||
36 | */ |
||
37 | 678 | public static function handleDynamic(&$context) { |
|
46 | |||
47 | /** |
||
48 | * Read partial file content as string and store in context |
||
49 | * |
||
50 | * @param array<string,array|string|integer> $context Current context of compiler progress. |
||
51 | * @param string $name partial name |
||
52 | * |
||
53 | * @return string|null $code compiled PHP code when success |
||
54 | */ |
||
55 | 97 | public static function read(&$context, $name) { |
|
74 | |||
75 | /** |
||
76 | * preprocess partial template before it be stored into context |
||
77 | * |
||
78 | * @param array<string,array|string|integer> $context Current context of compiler progress. |
||
79 | * @param string $tmpl partial template |
||
80 | * @param string $name partial name |
||
81 | * |
||
82 | * @return string|null $content processed partial template |
||
83 | * |
||
84 | * @expect 'hey' when input Array('prepartial' => false), 'hey', 'haha' |
||
85 | * @expect 'haha-hoho' when input Array('prepartial' => function ($cx, $tmpl, $name) {return "$name-$tmpl";}), 'hoho', 'haha' |
||
86 | */ |
||
87 | 86 | protected static function prePartial(&$context, $tmpl, &$name) { |
|
90 | |||
91 | /** |
||
92 | * resolve partial, return the partial content |
||
93 | * |
||
94 | * @param array<string,array|string|integer> $context Current context of compiler progress. |
||
95 | * @param string $name partial name |
||
96 | * |
||
97 | * @return string|null $content partial content |
||
98 | */ |
||
99 | 95 | public static function resolve(&$context, &$name) { |
|
109 | |||
110 | /** |
||
111 | * use partialresolver to resolve partial, return the partial content |
||
112 | * |
||
113 | * @param array<string,array|string|integer> $context Current context of compiler progress. |
||
114 | * @param string $name partial name |
||
115 | * |
||
116 | * @return string|null $content partial content |
||
117 | */ |
||
118 | 14 | public static function resolver(&$context, &$name) { |
|
124 | |||
125 | /** |
||
126 | * compile a partial to static embed PHP code |
||
127 | * |
||
128 | * @param array<string,array|string|integer> $context Current context of compiler progress. |
||
129 | * @param string $name partial name |
||
130 | * |
||
131 | * @return string|null $code PHP code string |
||
132 | */ |
||
133 | 9 | public static function compileStatic(&$context, $name) { |
|
151 | |||
152 | /** |
||
153 | * compile partial as closure, stored in context |
||
154 | * |
||
155 | * @param array<string,array|string|integer> $context Current context of compiler progress. |
||
156 | * @param string $name partial name |
||
157 | * |
||
158 | * @return string|null $code compiled PHP code when success |
||
159 | */ |
||
160 | 97 | public static function compileDynamic(&$context, $name) { |
|
173 | |||
174 | /** |
||
175 | * compile a template into a closure function |
||
176 | * |
||
177 | * @param array<string,array|string|integer> $context Current context of compiler progress. |
||
178 | * @param string $template template string |
||
179 | * @param string,integer $name partial name or 0 |
||
|
|||
180 | * |
||
181 | * @return string $code compiled PHP code |
||
182 | */ |
||
183 | 86 | public static function compile(&$context, $template, $name = 0) { |
|
210 | } |
||
211 | |||
212 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.