Skip to content

Using the Ghost Handlebars Match Helper

Today I was looking for a way to check if a post has a specific primary tag inside a loop, and I found the @Ghost match helper.

In this example, the match helper will check if the primary tag slug is “work”.

{{#match primary_tag.slug "work"}}

{{/match}}

Another use case with custom settings.

In this example, the match helper will check if the homepage_layout_style setting is “Default”.

{{#match @custom.homepage_layout_style "Default"}}

{{/match}}

The homepage_layout_style is a custom setting with the select type.

"homepage_layout_style": {
  "type": "select",
  "options": [
    "Default",
    "Image Right",
    "Image Circle",
    "Image Center",
    "Image Wide",
    "Image Full"],
  "default": "Default",
  "group": "homepage"
}

Hopefully, you find this helpful.

tutorials

Latest Ghost Themes