|
| 1 | +Double-check every LightnCandy issue where I left a comment, to see if any need to be updated following the helpers changes. |
| 2 | + |
| 3 | +- [x] https://github.com/zordius/lightncandy/issues/371 |
| 4 | +- [x] https://github.com/zordius/lightncandy/issues/360 |
| 5 | +- [x] https://github.com/zordius/lightncandy/issues/356 |
| 6 | +- [x] https://github.com/zordius/lightncandy/issues/350 |
| 7 | +- [x] https://github.com/zordius/lightncandy/issues/347 |
| 8 | +- [x] https://github.com/zordius/lightncandy/issues/346 |
| 9 | +- [x] https://github.com/zordius/lightncandy/issues/345 |
| 10 | +- [x] https://github.com/zordius/lightncandy/issues/341 |
| 11 | + |
| 12 | + |
| 13 | +Comment with fixed after release: |
| 14 | +- https://github.com/zordius/lightncandy/issues/292 |
| 15 | + |
| 16 | +Nested partials are fully supported, both at compile and render time in [PHP Handlebars](https://github.com/devtheorem/php-handlebars): |
| 17 | + |
| 18 | +```php |
| 19 | +use DevTheorem\Handlebars\{Handlebars, Options}; |
| 20 | + |
| 21 | +require 'vendor/autoload.php'; |
| 22 | + |
| 23 | +$templateString = '{{#>outer}} {{#>compiledBlock}} real inner compiledBlock {{/compiledBlock}} {{>normalTemplate}} {{/outer}}'; |
| 24 | + |
| 25 | +$template = Handlebars::compile($templateString, new Options( |
| 26 | + partials: [ |
| 27 | + 'outer' => 'outer+{{#>nested}}~{{>@partial-block}}~{{/nested}}+outer-end', |
| 28 | + 'nested' => 'nested={{>@partial-block}}=nested-end', |
| 29 | + ], |
| 30 | +)); |
| 31 | + |
| 32 | +echo $template(null, [ |
| 33 | + 'partials' => [ |
| 34 | + 'compiledBlock' => Handlebars::compile('compiledBlock !!! {{>@partial-block}} !!! compiledBlock'), |
| 35 | + 'normalTemplate' => Handlebars::compile('normalTemplate'), |
| 36 | + ], |
| 37 | +]); |
| 38 | +``` |
| 39 | + |
| 40 | +Output (matching Handlebars.js): |
| 41 | +> outer+nested=~ compiledBlock !!! real inner compiledBlock !!! compiledBlock normalTemplate ~=nested-end+outer-end |
| 42 | +
|
| 43 | +The second example also works correctly in PHP Handlebars, with both compile-time and runtime partials: |
| 44 | + |
| 45 | +```php |
| 46 | +use DevTheorem\Handlebars\{Handlebars, Options}; |
| 47 | + |
| 48 | +require 'vendor/autoload.php'; |
| 49 | + |
| 50 | +$templateString = '{ {{#>outer}} {{#>innerBlock}} Hello {{/innerBlock}} {{>simple}} {{/outer}} }'; |
| 51 | + |
| 52 | +$partials = [ |
| 53 | + 'outer' => '( {{#>nested}} « {{>@partial-block}} » {{/nested}} )', |
| 54 | + 'nested' => '[ {{>@partial-block}} ]', |
| 55 | + 'innerBlock' => '< {{>@partial-block}} >', |
| 56 | + 'simple' => 'World!', |
| 57 | +]; |
| 58 | + |
| 59 | +$templateWithPartials = Handlebars::compile($templateString, new Options(partials: $partials)); |
| 60 | +echo $templateWithPartials() . " (compile time)\n"; |
| 61 | + |
| 62 | +$templateWithoutPartials = Handlebars::compile($templateString); |
| 63 | +$compiledPartials = array_map(fn($p) => Handlebars::compile($p), $partials); |
| 64 | + |
| 65 | +echo $templateWithPartials(null, ['partials' => $compiledPartials]) . " (runtime)\n"; |
| 66 | +``` |
| 67 | + |
| 68 | +Output: |
| 69 | +> { ( [ « < Hello > World! » ] ) } (compile time) |
| 70 | +> { ( [ « < Hello > World! » ] ) } (runtime) |
| 71 | +
|
| 72 | + |
| 73 | +- Support callable for helper functions: https://github.com/zordius/lightncandy/issues/228 |
| 74 | + |
| 75 | + |
| 76 | +[Unable to resolve partial when using sub-expression and partial resolver](https://github.com/devtheorem/php-handlebars/issues/5) |
| 77 | +- Maybe comment with approach using helper rather than partial? |
0 commit comments