|
1 | 1 | LightnCandy |
2 | 2 | =========== |
3 | 3 |
|
4 | | -⚡🍭 An extremely fast PHP implementation of handlebars ( http://handlebarsjs.com/ ) and mustache ( http://mustache.github.io/ ). |
| 4 | +An extremely fast PHP implementation of [Handlebars](https://handlebarsjs.com/). |
5 | 5 |
|
6 | 6 | Features |
7 | 7 | -------- |
8 | 8 |
|
9 | 9 | * Compile template to **pure PHP** code. Examples: |
10 | 10 | * <a href="https://github.com/zordius/HandlebarsTest/blob/master/fixture/001-simple-vars.tmpl">Template A</a> generated <a href="https://github.com/zordius/HandlebarsTest/blob/master/fixture/001-simple-vars.php">PHP A</a> |
11 | 11 | * <a href="https://github.com/zordius/HandlebarsTest/blob/master/fixture/016-hb-eachthis.tmpl">Template B</a> generated <a href="https://github.com/zordius/HandlebarsTest/blob/master/fixture/016-hb-eachthis.php">PHP B</a> |
12 | | -* **FAST!** |
13 | | - * Runs 2~7 times faster than <a href="https://github.com/bobthecow/mustache.php">mustache.php</a> (Justin Hileman/bobthecow implementation). |
14 | | - * Runs 2~7 times faster than <a href="https://github.com/dingram/mustache-php">mustache-php</a> (Dave Ingram implementation). |
15 | | - * Runs 10~50 times faster than <a href="https://github.com/XaminProject/handlebars.php">handlebars.php</a>. |
16 | | - * Detail performance test reports can be found <a href="https://github.com/zordius/HandlebarsTest">here</a>, go http://zordius.github.io/HandlebarsTest/ to see charts. |
17 | | -* **SMALL!** all PHP files in 189K |
18 | 12 | * **ROBUST!** |
19 | 13 | * Supports almost all <a href="https://github.com/jbboehr/handlebars-spec">handlebars.js spec</a> |
20 | 14 | * Output <a href="https://github.com/zordius/HandlebarsTest/blob/master/FEATURES.md">SAME</a> with <a href="https://github.com/wycats/handlebars.js">handlebars.js</a> |
@@ -66,7 +60,7 @@ LightnCandy::compile($template, array( |
66 | 60 | * <a href="https://zordius.github.io/HandlebarsCookbook/LC-FLAG_NOESCAPE.html">FLAG_NOESCAPE</a> |
67 | 61 | * <a href="https://zordius.github.io/HandlebarsCookbook/LC-FLAG_PARTIALNEWCONTEXT.html">FLAG_PARTIALNEWCONTEXT</a> |
68 | 62 | * `FLAG_IGNORESTANDALONE` : prevent standalone detection on `{{#foo}}`, `{{/foo}}` or `{{^}}`, the behavior is same with handlebars.js ignoreStandalone compile time option. |
69 | | -* `FLAG_PREVENTINDENT` : align partial indent behavior with mustache specification. This is same with handlebars.js preventIndent copmile time option. |
| 63 | +* `FLAG_PREVENTINDENT` : Prevent indented partial-call from indenting the entire partial output by the same amount. Same as the Handlebars.js `preventIndent` compile option. |
70 | 64 |
|
71 | 65 | **PHP** |
72 | 66 | * <a href="https://zordius.github.io/HandlebarsCookbook/LC-FLAG_RUNTIMEPARTIAL.html">FLAG_RUNTIMEPARTIAL</a> |
@@ -288,21 +282,6 @@ Here are the list of LightnCandy\Runtime debug options for render function: |
288 | 282 | * `DEBUG_TAGS_ANSI` : turn the return value of render function into normalized mustache tags with ANSI color |
289 | 283 | * `DEBUG_TAGS_HTML` : turn the return value of render function into normalized mustache tags with HTML comments |
290 | 284 |
|
291 | | -Preprocess Partials |
292 | | -------------------- |
293 | | - |
294 | | -If you want to do extra process before the partial be compiled, you may use `prepartial` when `compile()`. For example, this sample adds HTML comments to identify the partial by the name: |
295 | | - |
296 | | -```php |
297 | | -$php = LightnCandy::compile($template, array( |
298 | | - 'prepartial' => function ($context, $template, $name) { |
299 | | - return "<!-- partial start: $name -->$template<!-- partial end: $name -->"; |
300 | | - } |
301 | | -)); |
302 | | -``` |
303 | | - |
304 | | -You may also extend <a href="https://zordius.github.io/lightncandy/class-LightnCandy.Partial.html">LightnCandy\Partial</a> by override the <a href="https://zordius.github.io/lightncandy/class-LightnCandy.Partial.html#_prePartial">prePartial()</a> static method to turn your preprocess into a built-in feature. |
305 | | - |
306 | 285 | Customize Render Function |
307 | 286 | ------------------------- |
308 | 287 |
|
@@ -337,11 +316,9 @@ Detail Feature list |
337 | 316 | Go http://handlebarsjs.com/ to see more feature description about handlebars.js. All features align with it. |
338 | 317 |
|
339 | 318 | * Exact same CR/LF behavior with handlebars.js |
340 | | -* Exact same CR/LF bahavior with mustache spec |
341 | 319 | * Exact same 'true' or 'false' output with handlebars.js |
342 | 320 | * Exact same '[object Object]' output or join(',' array) output with handlebars.js |
343 | 321 | * Can place heading/tailing space, tab, CR/LF inside `{{ var }}` or `{{{ var }}}` |
344 | | -* Indent behavior of the partial same with mustache spec |
345 | 322 | * `{{{value}}}` or `{{&value}}` : raw variable |
346 | 323 | * true as 'true' |
347 | 324 | * false as 'false' (require `FLAG_TRUE`) |
|
0 commit comments