简体   繁体   中英

converting a jade if statement to handlebars (hbs)

I've been following this tutorial and I've been able to convert each jade line to hbs apart from this one;

- if (user_open.id != user.id)

I tried this;

{{#if "user_open.id != user.id" }}

but it doesn't seem to work. Any ideas???

Handlebars is logicless so you can't use the != operator directly. You'll need to pre-compute in javascript a boolean value you can pass to the template when you render such as isOther so you can do {{#if isOther}} in your template or create a block helper function so you can do {{#isOther user user_open}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM