-
-
Notifications
You must be signed in to change notification settings - Fork 1
Handlebars: Partials
Bruno Meilick edited this page Mar 8, 2020
·
1 revision
Partials are stored at /site/template/partials
. Think of them as reusable blocks injected into your handlebars templates before they get compiled.
/site/templates/partials/piece-of-cake.hbs
Piece of {{ cake }}
/site/templates/call-a-partial.hbs
{{> @piece-of-cake this }}
Note:
@
andthis
are used by the JS version of Handlebars in Fractal to denote a partial and forward the data. Both will be automatically removed on PHP compilation by this plugin.
/content/pizza/call-a-partial.txt
Title: 🍕
/site/controllers/call-a-partial.php
<?php
return function ($site, $page, $kirby) {
return ['cake' => $page->title()]; // cake => 🍕
};
localhost:80/pizza
Piece of 🍕
bnomei.handlebars. | Default | Description |
---|---|---|
dir-partials | callback |
returning kirby()->roots()->templates().'/partials'
|