File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use DevTheorem \Handlebars \{Handlebars , HelperOptions };
4+
5+ require 'vendor/autoload.php ' ;
6+
7+ $ template = Handlebars::compile ('{{> (loadPartial partialName)}} ' );
8+
9+ $ helpers = [
10+ 'loadPartial ' => function (string $ name , HelperOptions $ options ): string {
11+ if (!$ options ->hasPartial ($ name )) {
12+ $ partial = file_get_contents (__DIR__ . '/ ' . $ name . '.hbs ' );
13+ $ options ->registerPartial ($ name , Handlebars::compile ($ partial ));
14+ }
15+ return $ name ;
16+ },
17+ ];
18+
19+ $ data = ['partialName ' => 'partial ' ];
20+ echo $ template ($ data , ['helpers ' => $ helpers ]);
Original file line number Diff line number Diff line change 1+ - [x] https://github.com/zordius/lightncandy/issues/371
2+ - [x] https://github.com/zordius/lightncandy/issues/360
3+ - [x] https://github.com/zordius/lightncandy/issues/356
4+ - [x] https://github.com/zordius/lightncandy/issues/350
5+ - [x] https://github.com/zordius/lightncandy/issues/347
6+ - [x] https://github.com/zordius/lightncandy/issues/346
7+ - [x] https://github.com/zordius/lightncandy/issues/345
8+ - [x] https://github.com/zordius/lightncandy/issues/341
9+ - [x] https://github.com/zordius/lightncandy/issues/318
10+ - [x] https://github.com/zordius/lightncandy/issues/299
11+ - [x] https://github.com/zordius/lightncandy/issues/297
12+ - [x] https://github.com/zordius/lightncandy/issues/296
13+ - [x] https://github.com/zordius/lightncandy/issues/294
14+ - [x] https://github.com/zordius/lightncandy/issues/293
15+ - [x] https://github.com/zordius/lightncandy/issues/292
16+ - [ ] https://github.com/zordius/lightncandy/issues/268 - maybe add comment with PHP Handlebars demo
17+ - [ ] https://github.com/zordius/lightncandy/issues/266 - investigate later
18+ - [ ] https://github.com/zordius/lightncandy/issues/242 - comment that simpler in PHP Handlebars
19+ - [ ] https://github.com/zordius/lightncandy/issues/228 - Comment with note about first-class callable syntax
20+
21+ - [x] https://github.com/devtheorem/php-handlebars/issues/5
You can’t perform that action at this time.
0 commit comments