Skip to content

Commit 6901d46

Browse files
committed
Rewrite section on templates
1 parent 3eacd74 commit 6901d46

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,27 @@ Templating
2424
Templates can be loaded from the file system. The following loads and transforms the template *src/main/handlebars.handlebars*:
2525

2626
```php
27-
use com\handlebarsjs\{HandlebarsEngine, FilesIn};
27+
use com\handlebarsjs\HandlebarsEngine;
2828

29-
$engine= (new HandlebarsEngine())->withTemplates(new FilesIn('src/main/handlebars'));
29+
$engine= (new HandlebarsEngine())->withTemplates('src/main/handlebars');
3030
$transformed= $engine->transform('hello', [
3131
'name' => 'World'
3232
]);
3333
```
3434

35+
Templates can also be declared inline:
36+
37+
```php
38+
use com\handlebarsjs\HandlebarsEngine;
39+
40+
$engine= (new HandlebarsEngine())->withTemplates(['test' => 'Hello {{name}}']);
41+
$transformed= $engine->transform('hello', [
42+
'name' => 'World'
43+
]);
44+
```
45+
46+
If you need more flexibility, you can implement and then pass instances of `com.github.mustache.templates.Templates`.
47+
3548
Helpers supported
3649
-----------------
3750
The following helpers are built in:

0 commit comments

Comments
 (0)