variable within context not passed to helper, but helper can see it the context #2021
Closed
DannyJoinedApps
started this conversation in
General
Replies: 1 comment
-
Sorry, good thing I didn't log this as an issue - I was wrong. Was getting confused. I called that helper from many places and it was not the call from the location I thought it was and the variable in question was indeed not present in the other scope. My bad. Will close! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Sorry, this should perhaps be an issue, but wasn't sure if its just be being silly.
I have a helper that was defined as:
hb.registerHelper("ifNotEquals", function (arg1, arg2, options) { return arg1 == false ? options.fn(this) : options.inverse(this); });
I call it from the template with:
{{#ifNot hasComment}}There is no comment!{{/ifNot}}
That reference is inside a large nested loop working through a big js object. 'hasComment' consistently in the object. I've really checked!
This mostly works, but very consistently doesn't work for just some data. I'm trying to work out whats confusing it about the data that doesn't work, but the wierd thing is this: when I pass the whole context (via 'this') to the helper, it clearly does contain the variable.
{{#ifNot hasComment this}}There is no comment!{{/ifNot}}
In the log entry showing the whole context I can see 'hasComment', and in the one spitting out 'context.hasComment' the true/false is visible.
So its as if handlebars cannot see the 'hasComment' within its interpreting environment and doesn't pick it out of the context but does happily pass it to the helper inside the context.
If anyone can think of a more cunning way to get to the bottom of this, I'd really appreciate the help. I can only think the object got too big or something.
Beta Was this translation helpful? Give feedback.
All reactions