JavaScript Handlebars, how to set a condition for a value returned by a helper

I'm using a handlebar helper for calculating how many rows there is in an array. If it's above 2 it returns true, and it works as it's suppose to. Looks like this:

define('templates/helpers/countRows', ['handlebars'], function ( Handlebars ) {
    function countRows(selectedArray) {
        var selectedArrayLength = selectedArray.length;
        if (parseInt(selectedArrayLength) > 2) {
            return true;
        }
    }
    Handlebars.registerHelper('countRows', countRows);
    return countRows;
});

The problem is that I want to set a condition in my hbs template to check if the value is true or not before outputting it. If it isn't true, I don't want it to output. I was hoping I could do something like this:

{{#if countRows "my array"}}
    markup that only gets displayed if value is true
{{/if}}

But this isn't valid unfortunately..

Answer:1

I'm working on creating a Hash Table in Javascript to better understand the data structure. I implemented it with a Linked List at each table position to deal with conflicts. The problem is that I ...

I'm working on creating a Hash Table in Javascript to better understand the data structure. I implemented it with a Linked List at each table position to deal with conflicts. The problem is that I ...

I'm pretty new with angular and I've read a lot of threads here and googled this topic but I cannot get a clear answer. What I'm trying to do is pass a value that is not set until the user makes a ...

I'm pretty new with angular and I've read a lot of threads here and googled this topic but I cannot get a clear answer. What I'm trying to do is pass a value that is not set until the user makes a ...

Consider sample html code: <head> .... <script src="/js/MyClass.js"></script> <script src="/js/extend.js"></script> <script> $(document)....

Consider sample html code: <head> .... <script src="/js/MyClass.js"></script> <script src="/js/extend.js"></script> <script> $(document)....

  1. method overloading javascript
  2. method overload js

In the following code, I have two Book Collections. One collection has "Moby Dick," while the other collection has "The Firm." However, when I look at the second collection, it also has Moby Dick. How ...

In the following code, I have two Book Collections. One collection has "Moby Dick," while the other collection has "The Firm." However, when I look at the second collection, it also has Moby Dick. How ...