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
Resolve #589, and possibly fix other manifestations of this bug #618
Conversation
@raymond-lam Thanks! Looks good! I think it would be nice to release this as a major version. I fear that some people might have bumped into this non-intended behavior and taken it as a feature, therefore we would be breaking their app/render. Thoughts? /cc @phillipj |
@dasilvacontin Thanks! You might be right. So what would that mean -- would we wait before merging this PR, or simply that the next release would be a major one? /cc @phillipj |
@raymond-lam Ideally, it would be nice to check if there are other fixes to review and merge before bumping the version. I don't have time to check stuff, I just somehow bumped into this PR. Maybe @phillipj, or someone (?). (Personally busy til Jan 21th) Do you have any hurry in getting this merged? |
@dasilvacontin no hurry -- just curious as to what the process was. Thanks! |
I would expect to be able to output diff --git a/test/_files/dot_notation.mustache b/test/_files/dot_notation.mustache
index 2640514..8b6b2e9 100644
--- a/test/_files/dot_notation.mustache
+++ b/test/_files/dot_notation.mustache
@@ -8,3 +8,4 @@
<p>Zero: {{truthy.zero}}</p>
<p>False: {{truthy.notTrue}}</p>
<p>length of string should not be rendered: {{price.currency.name.length}}</p>
+<p>length of an array should be rendered: {{authors.length}}</p>
diff --git a/test/_files/dot_notation.txt b/test/_files/dot_notation.txt
index eeb346d..98d2e6a 100644
--- a/test/_files/dot_notation.txt
+++ b/test/_files/dot_notation.txt
@@ -8,3 +8,4 @@
<p>Zero: 0</p>
<p>False: false</p>
<p>length of string should not be rendered: </p>
+<p>length of an array should be rendered: 2</p> Completely agree doing a major version bump, better safe than sorry. No other upcoming breaking changes as I know of, so this would be good to go as soon as it lands IMO. And thanks for fixing this 👍 |
@phillipj I think we should check the specs 😅 . afaik, Mustache templates should be language agnostic. |
Hah, that's a very good point. Pretty sure I used it a lot when reusing templates between java & JS tho. That brings the philosophical question of whether or not we should prevent I'm leaning towards letting it be resolvable. Not everyone has the need to use templates across different languages. And as mentioned, I'm pretty sure it's completely valid between java and JS. Us deliberately hiding something that's obviously useful in many scenarios feels strange, doesn't it? On second thought the exact same could be said about not being able to resolve |
I feel there should be a standard way of printing the length of a Maybe other Mustache implementations have come up with a |
@phillipj @dasilvacontin As far as this particular PR goes, the accessibility of As to the question of whether If we wanted to change the accessibility of properties like This brings up another case, though perhaps a less worthy one:
How should this render? Given all of this, how should we proceed with this PR? (Should I still add the tests that @phillipj suggested?) |
Absolutely 👍 Maybe the always wise @bobthecow has some thoughts on this one? |
Whoops -- fixed typo in the |
Also another point -- if we decided to make properties of boxed primitives (and functions for that matter) consistently accessible (which obviously would require revisions to this PR), then that would make this PR not a breaking change and we wouldn't have to do a major version bump, right? |
Hmm. Making properties available where previously weren't would stop property lookup to previous contexts. That would probably need to go to a major as well. |
@dasilvacontin Oh, right. |
@dasilvacontin @phillipj @bobthecow Hi everyone, Thanks, |
@dasilvacontin @phillipj @bobthecow Hi everyone, Thanks, |
Sorry this stalled, really sorry but thanks for your patience! As I've stated before, I'm all for consistency which this PR seems to improve. Personally from a user's perspective, find it less than ideal that Since it sounds like these changes has to be released in a new major version anyways, I'd rather see Bottom line is I'd prefer the simplicity of being able to render what is available, over mustache spec compliance for the sake of strictness. @dasilvacontin you agree? |
One such bad effect might be that the |
(BTW I added the |
Thanks 👍 Whether or not we end up exposing |
Okay, let me state my thoughts in case I'm wrong:
So, if we removed that constrain and made string's length able to be rendered, we could release this as a |
Btw, sorry for the stalling @raymond-lam! |
I agree with your comments @phillipj. Actually, due to #618 (comment), making string's length renderable would need to be a |
Apparently (typeof obj === 'object' ? (propName in obj) : obj.hasOwnProperty(propName)) Feel free to revert/delete my commit. I can't work on it right now. |
I've fixed the issue from @dasilvacontin's change where one cannot use So, I've pushed another commit, which mostly undoes the changes by @dasilvacontin but makes String.length rendering possible through dot notation, while still passing the 'bug_length_property' test. I'm not sure how I feel about this fix, but I guess one could rationalize that if you're using dot notation to access a property, you really mean to access that property. |
Also just added a test to address the original issue as reported specifically. |
Hi @dasilvacontin, @phillipj, |
LGTM 👍 Thanks for a good discussion and being very patience. I'll let this be open for a few days in case @dasilvacontin has any other thoughts, or merge it within the end of this week -- I'm creating a reminder for my self so this won't stall again. |
@dasilvacontin BTW, if you have the time, would love to hear your thoughts on #643 while we are here. |
@dasilvacontin Just wanted to bump this thread so that we didn't forget about this PR. |
Allows rendering properties of primitive types that are not objects, such as a string.
…tives possible through dot notation
…plain why it is used in one case but not the other
@dasilvacontin @phillipj just wanted to bump this PR, as it's been quite some time now. Thanks! |
It’s been on my mind like every week 😅. I think mid-May might be good.
… On 26 Apr 2018, at 14:58, Raymond Lam ***@***.***> wrote:
@dasilvacontin @phillipj just wanted to bump this PR, as it's been quite some time now. Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@dasilvacontin Great, thanks! FYI I will be traveling for much of the summer, so I may not be able to respond to any comments until later in the summer. |
No worries, enjoy the trip(s)! :)
… On 27 Apr 2018, at 05:20, Raymond Lam ***@***.***> wrote:
@dasilvacontin Great, thanks! FYI I will be traveling for much of the summer, so I may not be able to respond to any comments until later in the summer.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@dasilvacontin I'm back from traveling -- just wanted to check in on this :) |
Same old :(. Maybe the PR should move on without my review, I haven’t been a maintainer in the project for a long while already.
David
… Le 20 juil. 2018 à 20:50, Raymond Lam ***@***.***> a écrit :
@dasilvacontin I'm back from traveling -- just wanted to check in on this :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@dasilvacontin No problem. Who do you recommend to look at it then? @phillipj ? |
As before, I'm very positive to these changes. Greatly appreciate both the tests and the added thorough comments. For the sake of being extra cautious and signal to users of mustache.js that changes has landed that might cause different output compared to before, I'd like to see these changes be part of a new major version. I haven't published a new version before, but I'll give it a go within a week or two. Just came back from vacation and need some warmup time before giving the release script a go 😄 Again, thanks for your extreme patience! |
I don't have the resources to commit to maintaining anymore.
@phillipj That sounds great — thanks! |
Short update to inform I'm getting to this PR eventually, v2.3.1 got published yesterday. |
Thanks for sharing and being explicit about it 👍 mustache.js wouldn't be the same without your hard work, much appreciated! |
@phillipj You're welcome! Neither without your hardwork either! Sorry for not having "given up" earlier, I was hoping for a comeback :). Will mention mustache.js if I ever talk at a JS event again! (I'm not so much in the community anymore since most talks are about front-end frameworks/libraries and not interesting in them atm) |
@raymond-lam as there might seem to be a custom tags regression in the newly released v2.3.1, I'm holding this off until we've got that fixed. Don't want to add more changes to the mix while digging into what's causing that regression. |
@phillipj Excellent! Thank you for all your help! Glad we got this thing merged in. |
Resolve #589
Because
value
is used as an intermediate variable as well as the final return value oflookup
, there is a possibility thatvalue
is returned even if thehasProperty
test fails. In the reported issue, the string'slength
is stored invalue
, even thoughlookupHit
isfalse
(because a string has alength
property but is not anObject
). The outer loop breaks, andvalue
is returned, incorrectly as the string'slength
.lookup
should never return a value where the lookup is not hit, so don't usevalue
as an intermediate variable -- only assign to it when we know that thehasProperty
test passes.