If current post has X Tag, Do this

Seems very simple but i’m not sure i’m doing it right because its not working.

I want to see if a tag (HIDDEN TAG #) is present in the current post, and if it is, display this line of code.

Here is my code (located inside a partial, not in post.hbs)

{{#post}}
    {{#has tag="#electronics"}}
        <div class="blah">Do this</div>
    {{/has}}
{{/post}}

I tried with both a normal tag and hidden tag to make sure it wasnt the hidden tag part breaking it, but its not.

Can you check that you’re not going into an undefined context? e.g.

{{#post}}

{{! begin partial }}
{{#post}}
    {{#has}}...
{{/post}}
{{! end partial }}


This is a post
{{/post}}

Would cause the context to be undefined (because post doesn’t have a post property) which means the has helper always returns false. Another thing you can do is use the else block to debug - e.g.

{{#has tag="hash-electronics"}}
   omg yes it works
{{else}}
  Tag list: {{tags}}
{{/has}}

OK i will try this, so i need to wrap {{#post}} around each partial to give it context? I believe this partial is nested 2 layers deep. So that would mean I need to have:

{{#post}}
     (partial1)
          {{#post}}
              (partial2)
                  {{#post}}
                         <html>
                  {{/post}}
         {{/post}}
{{/post}}

No, I’m saying it’s the other way around - If in the outer template you’re in the post context, the partial will also be in the post context -

{{#post}}
    {{!--  Partial --}}
    {{!-- Prints post title --}}
    The title at the top of the partial is: {{title}}
    {{#post}}
        {{!-- no title --}}
       The title after trying to go into the non-existent post context is: {{title}}
    {{/post}}
{{/post}}