Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

424
Views
Handlebars does not recognize helper

I found this helper online that checks whether a variable is equal to a certain string. I tried to add this helper to my index.hbs file, but I get the following error: Missing helper: "if_eq"

Can someone tell me how I can fix this? I did what they asked me to do in in the official Handlebars docs, so I don't understand. I use NodeJS/Express, but without require('handlebars') or require('express-handlebars'), because that's how express-generator generated it for me.

index.hbs:

<script>
Handlebars.registerHelper('if_eq', function(a, b, opts) {
    if(a == b)
        return opts.fn(this);
    else
        return opts.inverse(this);
});
</script>

{{#each tasks}}
    {{#if_eq status 'unfinished'}}
        [do something]
    {{else}}
        [do something else]
    {{/if_eq}}
{{/each}}
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

express-generator uses: hbs package as you can see in here:

enter image description here

So you need to first register the helper in the server side, like this:

const hbs = require('hbs');
const express = require('express');
const app = express();

app.set('view engine', 'hbs');

hbs.registerHelper('if_eq', function(a, b, opts) {
    if(a == b)
        return opts.fn(this);
    else
        return opts.inverse(this);
});
//... rest of your server code

Drop the helper from index.hbs since that's for registering the helper in the client side, and you're rendering handlebars in the server side.

index.hbs

{{#each tasks}}
    {{#if_eq status 'unfinished'}}
        [do something]
    {{else}}
        [do something else]
    {{/if_eq}}
{{/each}}
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!