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


#1
    {{#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.


#2

Event not working too

{{#if excerpt}}
      <p class="desc">{{excerpt}}</p>
{{/if}}

#3
{{#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.


#4

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

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

what is this for ?
Thanks


#5

Well {{content}} is a helper within the ghost. But Here I have used as a block expression like {{#post}}{{/post}} https://themes.ghost.org/docs/handlebars#section-block-expressions-scopes-
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 ( https://themes.ghost.org/docs/is#section-contexts ). 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.


#6

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