If condition is not working on ever {{ content }}

    {{#post}}
        {{#if content}}
            <div class="container page-header-bottom-contents">
                <div class="row">
                    <div class="col-md-10 mx-auto">
                        {{ content }}
                    </div>
                </div>
            </div>
        {{/if}}
    {{/post}}

I want this whole div will render only when there will be content on page, unfortunately when I wrap these via {{#if}} .. {{/if}} no content renders, even when there are content exits.

I know , maybe I have some misconception here. Please make me correct.

Event not working too

{{#if excerpt}}
      <p class="desc">{{excerpt}}</p>
{{/if}}
{{#post}}
        {{#content}}
            <div class="container page-header-bottom-contents">
                <div class="row">
                    <div class="col-md-10 mx-auto">
                        {{ content }}
                    </div>
                </div>
            </div>
        {{/content}}
{{/post}}

This should do what you want. BTW {{content}} may output empty <p></p> when there is no content available.

Hi @GBJsolution , thats for your time.
Can you please explain

{{#content}} {{/content}}

what is this for ?
Thanks

Well {{content}} is a helper within the ghost. But Here I have used as a block expression like {{#post}}{{/post}} Ghost Handlebars Themes - Building a custom Ghost theme - Docs
This type of use is not documented anywhere. But it works the way you want the output.

Also another way to use it is

{{#is content}}{{/is}}

Although the {{is}} helper actually used for checking context and “content” is not supported context for is helper ( Ghost Handlebars Themes - Building a custom Ghost theme - Docs ). but it solve your purpose. even {{is}] helper does not output the empty

tag.

Actually you can say these are some sort of hacks. Because these are not documented anywhere.

Don’t know, how the content area designed in your theme, but generally speaking, you don’t need to check also whether is there is content available or not. Because, A post should have some sort of content there.

1 Like

Thank you so much for this. I was into this issue and tired to tinker around to check if its possible but couldnt get it done. Now that i have seen the way you did it, thanks guys
with
regards

I’m trying this, but {{#content}} {{/content}} output the content the same as {{ content }}.

Try this, I have tested this now and it’s working.

{{#if html}}
 has some content
 {{else}}
 has no content
{{/if}}

OR

{{#unless html}}
 has no content
 {{else}}
 has some content
{{/unless}}

Logic, {{#if}} helper takes one argument and return false if it is set to null. If there is no content added to the post then the html property set to null.

If the post has content but visibility set to members or private and new “content preview” card has not been added, then the html property set to an empty string. In both case {{#if}} helper returns false.

I don’t know your use case and I have not tested with members logged in state. But generally it should work.

You can also play with excerpt and plaintext property of a post.

It works. It seems to work fine with the new Public Review card as well. Thank you!

Weirdly, it is not documented anywhere, and I’m afraid to be deprecated without notice.