-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Looking up in parent context on foo: null is contrary to RFC #397
Comments
👍 - can't find any good way around this issue myself - thinking about switching to another template engine if I can't get a solution :( |
Cool, good luck elsewhere. I hear handlebars is nice.
|
Handlebars is nice but it does not check parent context at all. Object.prototype.noupcontext = function () {
var me = this;
return function(val, render) {
return me[render(val)];
};
}; and {{#noupcontext}}name{{/noupcontext}} |
I was just commenting on your subtle thread to leave mustache if your problem isn’t addressed. This is a volunteer project and people threatening the volunteers is not something I’d like to see in this project. Good luck elsewhere. |
who are you talking to? I was just helping |
I’m referring to @billymoon. |
Just for using in my project in Context.prototype.lookup function I changed if (value != null)
break; to if (value !== undefined)
break; Anyone can tell why it could be wrong? |
@Roman600 I think |
@bubbatls I checked your method, and it works. I will need to make some tweaks to fit my case exactly (how to include strings not in the data when the element exists in the data, and hopefully implement without changing |
@Roman600 solution seams far better than mine. In my mind it can be wrong only for the thousands (millions ?) existing templates around the world that expect null to be handled as undefined. |
See PR #407. |
This is a bug since, as @Roman600 mentioned, there is actually a key. Specially for the case the key has
For keys having |
Any thoughts about not checking parent contexts if the current context has the key, regardless of it's value (even |
Changing the default here isn't something that should be taken lightly. Even if it's to move to something that makes more sense, it'll break a lot of existing apps and sites. Maybe it would make sense to add a config option for this? |
@bobthecow, indeed, that's my main concern about it; even though it's something spec-compliant, I'm sure that a lot of people rely on About the config option, do you have any suggestion/ideas? A pragma, programatic/API, ...? |
or new major version, yay SemVer. |
@janl, well, |
yeah, that needs fixing too, realise the current version as 1.0.0 and move on from there :) |
What else do you want feedback on, there? :)
|
@janl Solved. :) |
A key with |
Fixed in a020430 |
Oh, that commit is from when I believed writing 'fixes' once before a bunch of issue numbers was enough. 😄 |
Mustache RFC:
But I do have a property in children object and it's value is null (which is false in some way). And I expect nothing to be rendered, but instead mustache.js looks up for a value in parent context and finds it, and shows it. But it's parent's value, not children's. And children has it's own value, and it's null. So according to RFC looking up doesn't need to be done.
The same thing happens not with only variables {{key}}, but with sections {{#key}}{{/key}} too.
The text was updated successfully, but these errors were encountered: