express-handlebars icon indicating copy to clipboard operation
express-handlebars copied to clipboard

How to use Logical OR/ '||' operator in nodejs Handlebars ?

Open JigneshPatel04 opened this issue 6 years ago • 2 comments

Hello,

I am using nodejs handlebars .

I used input field and i have applied || condition in my code . but error occurred on it. Like as below

Error: Parse error on line 9: ...alue="{{#if editing || hasError }} {{pro -----------------------^ Expecting 'CLOSE_RAW_BLOCK', 'CLOSE', 'CLOSE_UNESCAPED', 'OPEN_SEXPR', 'CLOSE_SEXPR', 'ID', 'EQUALS', 'OPEN_BLOCK_PARAMS', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', 'SEP', got 'CLOSE_BLOCK_PARAMS' at Parser.parseError (G:\Learning\Course\Node\Maximilian-Node_Complete_

Any one idea ?

JigneshPatel04 avatar Aug 01 '19 07:08 JigneshPatel04

https://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional

You will have to create a block helper for that. handlebars.js doesn't have a built in way to do that.

UziTech avatar Aug 01 '19 16:08 UziTech

handlebars-helpers is a package that has a bunch of useful block helpers.

UziTech avatar Aug 01 '19 16:08 UziTech