Usage of #has helper in tag.hbs to display content based on slug

Hello,

I’m looking to display conditionnal content based on the chosen tag/slug (in this page https://site.ghost/tag/\<slug>)

I was thinking about doing something like {{#has slug=“<slug>”}} content {{/has}}. I tried a lot of things like slug.<slug>, tag.<slug>, with and without quotes but none of them worked. The help page Ghost Handlebars Theme Helpers: has did not help me. This meaning of this is not clear for me:

{{#has slug="welcome"}}{{/has}}
{{#has slug=../../slug}}{{/has}}
{{#has id=post.id}}{{/has}}

I do not have any specific route configured.

Would you clarify this to me?

Thank you!
Steven

Did you make sure to place the #has within the context of {{#tag}}…{{/tag}}? I just tried the following and it appears to be working fine:

{{#has slug="getting-started"}}
    <p>This is getting started</p>
{{/has}}

Aah OK, this is the option I missed. I did not understand we have to add the context. I thought it was implicitly inherited from the main page.

It works now.

Thank you very much.

1 Like