How to pass values into a partial Ghost template

"Partials" in Ghost are bits of HTML that can be used within other template files. They always live in the /partials folder of a theme.

You can include  them within a template like this:

<div>
  {{> "comments"}}
</div>

This would load the HTML from partials/comments.hbs into the page.

In some cases, you may want to pass data into a partial from the parent template file.

This is done simply by listing the data after the partial name, like this:

<div>
  {{> "comments" show_something=true}}
</div>

A good example of this in use is in the Substation theme (see a demo), which allows some customisation of the main post list.

Using a three variables within the partial, the publisher can choose whether or not to show/hide author names, post tags and the excerpt.

{{> "post-card" show_excerpt=true show_tag=false show_authors=false}}