dark night
dark night

Reputation: 171

node.js handelbars Error: Missing helper: "compare"

when I run this code to comparing value if it bigger than one i get this error

{{#compare pageCount ">" 1 }}
  <ul class="pagination"><­/ul>
    {{#compare currentPage ">" 1 }}

       <li><a href="/?page=1"> &laquo;</a></li>
    {{/compare}}

{{/compare}}

i installed handelbars with node.js and i tested it but i get this error always when i use compare hash ?

Error: Missing helper: "compare"
    at Object.<anonymous> (/opt/lampp/htdocs/x/chessMult/regtest/using-passport-with-sequelize-and-mysql-master/node_modules/handlebars/dist/cjs/handlebars/helpers/helper-missing.js:19:13)
    at Object.eval (eval at createFunctionContext (/opt/lampp/htdocs/x/chessMult/regtest/using-passport-with-sequelize-and-mysql-master/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23),

:8:91) at main (/opt/lampp/htdocs/x/chessMult/regtest/using-passport-with-sequelize-and-mysql-master/node_modules/handlebars/dist/cjs/handlebars/runtime.js:175:32) at ret (/opt/lampp/htdocs/x/chessMult/regtest/using-passport-with-sequelize-and-mysql-master/node_modules/handlebars/dist/cjs/handlebars/runtime.js:178:12) at ret (/opt/lampp/htdocs/x/chessMult/regtest/using-passport-with-sequelize-and-mysql-master/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:525:21) at ExpressHandlebars._renderTemplate (/opt/lampp/htdocs/x/chessMult/regtest/using-passport-with-sequelize-and-mysql-master/node_modules/express-handlebars/lib/express-handlebars.js:247:12) at ExpressHandlebars. (/opt/lampp/htdocs/x/chessMult/regtest/using-passport-with-sequelize-and-mysql-master/node_modules/express-handlebars/lib/express-handlebars.js:173:21)

Upvotes: 0

Views: 2663

Answers (1)

BaHaa Jr.
BaHaa Jr.

Reputation: 534

You must make a custom helper with Handlebars.registerHelper you can check the full documentation to know how to register a custom helper to be able to use it in the template.

Upvotes: 2

Related Questions