# Comparison helper

**URL:** <https://forum.ghost.org/t/comparison-helper/6653>\
**Category:** Ideas\
**Created:** [April 5, 2019, 6:12pm UTC](https://forum.ghost.org/t/comparison-helper/6653 "2019-04-05T18:12:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmckulka](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cmckulka/32/2965_2.png) [@cmckulka](https://forum.ghost.org/u/cmckulka)\
**Post date:** [April 5, 2019, 6:12pm UTC](https://forum.ghost.org/t/comparison-helper/6653/1 "2019-04-05T18:12:50Z")

</div>

It would be great if Ghost provided a comparison helper. For example `{{#if gt(pages, 1)}}`.

[ember-truth-helpers](https://github.com/jmurphyau/ember-truth-helpers) is a good example. They also implement booleans.

I would add them as a custom helper myself … but I can’t. ☹ I added vote to [that request](https://forum.ghost.org/t/custom-theme-hbs-helper/4038/4).

The scenario I was looking to solve is suppressing pagination when there is only one page, e.g. for featured posts. The `if` helper won’t work because `pages` is always at least 1 (if nothing featured I suppress the whole section). `has` doesn’t help here either.

Even using javascript is tricky because, in my scenario, I have two pagination blocks on the home page. I could probably solve it passing a parameter to the partial but it feels pretty clunky.

---

<div class="post-metadata">

**Author:** ![Hannah](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/hannah/32/22_2.png) [@Hannah](https://forum.ghost.org/u/Hannah)\
**Post date:** [April 5, 2019, 6:56pm UTC](https://forum.ghost.org/t/comparison-helper/6653/2 "2019-04-05T18:56:09Z")

</div>

I can definitely see the use case for disabling pagination if there’s only one page. Passing a param to the partial is a sane workaround - we actually only recently made that possible for these sorts of cases.

Either way, achieving this nicely could be done with the introduction of a single boolean our side - it shouldn’t need a full suite of comparisons - but it is already possible with this logic:

```auto
{{#unless prev}}{{#unless next}}
.. there is neither a prev nor a next page
{{/unless}}{{/unless}}

```

---

<div class="post-metadata">

**Author:** ![Hannah](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/hannah/32/22_2.png) [@Hannah](https://forum.ghost.org/u/Hannah)\
**Post date:** [April 5, 2019, 6:58pm UTC](https://forum.ghost.org/t/comparison-helper/6653/3 "2019-04-05T18:58:22Z")

</div>

And I’ve just seen that Kevin gave you a different answer here:

> [@Custom theme hbs helper](https://forum.ghost.org/t/custom-theme-hbs-helper/4038/5):
>
> @cmckulka how to suppress pagination will depend on how you are rendering pagination but if you’re talking about the code inside pagination.hbs have you tried using the [{{has}} helper](https://docs.ghost.org/api/handlebars-themes/helpers/has/)? Eg: {{#has any="prev, next"}}...pagination...{{/has}} There shouldn’t be any need for custom helpers for what you are trying to do. If the {{has}} helper doesn’t work please open a new topic with more details about your template structure and exactly what you are trying to achieve.

We rarely find use cases that aren’t solved with the helpers that are already available :) Most custom helper requests are people misunderstanding what’s possible, or wanting to do something better served with client side JS.

When that isn’t the case, we’ll always consider extending the existing helpers 🙂

---

<div class="post-metadata">

**Author:** ![cmckulka](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/cmckulka/32/2965_2.png) [@cmckulka](https://forum.ghost.org/u/cmckulka)\
**Post date:** [April 5, 2019, 7:16pm UTC](https://forum.ghost.org/t/comparison-helper/6653/4 "2019-04-05T19:16:04Z")

</div>

I am new to Ghost and I really appreciate how responsive both you and the broader Ghost team are!! Makes me feel more confident in my choice.

@Kevin’s suggestion definitely solved this scenario (thanks!). Still learning my way around Ghost.

Coming from Jinja templates not being able to do comparisons in Handlebars is a weird limitation. That said I was using Jinja for much more complex sites / application functionality so it may be that for my publishing site they won’t be needed.

Thanks again!
