ericf / express-handlebars

A Handlebars view engine for Express which doesn't suck.
BSD 3-Clause "New" or "Revised" License
2.31k stars 384 forks source link

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

Open JigneshPatel04 opened 5 years ago

JigneshPatel04 commented 5 years ago

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-NodeComplete

Any one idea ?

UziTech commented 5 years ago

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 commented 5 years ago

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