helpers / handlebars-helpers

188 handlebars helpers in ~20 categories. Can be used with Assemble, Ghost, YUI, express.js etc.
http://assemble.io/helpers/
MIT License
2.22k stars 364 forks source link

Comparation(#compare var1 "==" var2) with two variables doesn't work #387

Open Noroxi opened 3 years ago

Noroxi commented 3 years ago

Hi I can't fix this, i search every where but nothing, here is my .hbs view:

    {{#each owners}} {{#each ../users}} {{#compare _id "==" ../_id}}
  • {{this.firstName}} {{this.lastName}}
  • {{/compare}} {{/each}} {{/each}}

But #compare doesn't work, when i use an _id as string and compare with any two variables it works, but when i use two variables it doesn't:

versions:

"handlebars": "^4.7.7", "handlebars-helpers": "^0.10.0", "handlebars-intl": "^1.1.2",

I'm using it with nodejs and express, please any help I'd try with #eqand #is but even it doesn't work !!

Devilthehell commented 3 years ago

Hey @Noroxi,

I am fairly new to GitHub, please forgive me for any mistakes. I ran a test in my system from inside of a withsort loop, and it worked just fine. ItemPrice and ItemsPrice are variables. They equal, and the "Equals" was produced.

{{#compare ItemPrice "==" ../ItemsPrice}} Equals {{/compare}}Outside: {{../ItemsPrice}} Inside: {{ItemPrice}}

The only thing that strikes me about the script you have, is that you are using:

{{#each ../users}}

Wouldn't this mean that you are going back out a level? Would this mean instead of using "../_id" you should use... "../owners._id"? I am just not sure how you are going outside to get into users, and then going outside for an "_id"? Let me know what you think.

Thank You.