How to use {{#has}} helper as a switch

Hi everyone,
I’m trying to use the {{else has}} helper to chain together multiple options like a switch statement, but it doesn’t work.

I’ve followed the official guide:

This is my code, please help me:

{{#has slug="…"}}

{{else has slug="…"}}


Thank you.

Handlebars doesn’t support elseif conditional logic :grimacing: (apparently it does)

You should be able to do it like this:

{{#has slug="a"}}
  Slug a!
  {{#has slug="b"}}
    Slug b!

Hi vikaspotluri123, thank you for your answer.
At this point I think there’s an error on the official documentation. What do you think?

Well I was absolutely mistaken!

I just tried it on the Casper theme with one of the default posts, and it worked:

{{#has tag="Fake Tags"}}
  Fake Tag
{{else has tag="Getting Started"}}
  It works
  Neither tag

Let’s try to debug your issue - is your code working with the nested condition option I mentioned?

Now it works, there was a problem with my slug.
Thank you!