Usage: {{{block "section"}}}
and {{#contentFor "section"}} content {{/contentFor}}
Description
{{{block "block-name"}}}
is a helper for creating a placeholder within a custom handlebars template. Adding the helper along with a unique ID creates a slot within the template, which can be optionally filled when the template is inherited by another template file.
The {{#contentFor "block-name"}}...{{/contentFor}}
helper is used to access and populate the block definitions within the template that’s being inherited. The inherited template is referenced with {{!< template-name}}
at the top of the file. If the contentFor
is not used then the block will be gracefully skipped.
Example
{{{body}}}
helper
The {{{body}}}
helper behaves in a similar fashion to a defined block helper, but doesn’t require a corresponding contentFor
helper in the inheriting template file.
{{{body}}}
example
Inherited template files, files that contain {{{block "block-name"}}}
, cannot be templates used directly by Ghost. post.hbs
, page.hbs
index.hbs
can inherit other template files and used the contentFor
helper but cannot contain block definitions. See our theme structure documentation for more information.