Skip to content
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

Add explicit braced property access parsing #260

Merged
merged 6 commits into from Oct 9, 2020

Conversation

wyozi
Copy link
Contributor

@wyozi wyozi commented Oct 9, 2020

Parses braced property accesses similar to how Ruby Liquid does it. Fixes #259

this.readTo(']')
return new PropertyAccessToken(prop, [], this.p)
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about ["foo"]["bar"] or ["foo"].bar?

We need adapt the following logic (the PropertyAccessToken part) to support this case (remove the variable constructor argument and make it the first props maybe?).

Copy link
Contributor Author

@wyozi wyozi Oct 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, although the number of potential valid syntaxes are getting a bit scary. Do you think that could be postponed into the future and this feature shipped as is (once I fix the tests passing)?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the number of potential valid syntaxes are getting a bit scary

Seems it can be done by consume the [, call readValue recursively(as in props brackets), and consume the ]. This way the following cases will be supported also:

{{["foo"].bar}}
{{[0].bar}}
{{[key].bar}}

@harttle harttle merged commit 30dffb6 into harttle:master Oct 9, 2020
@wyozi wyozi deleted the fix-brace-var-access branch October 9, 2020 13:21
@harttle
Copy link
Owner

harttle commented Oct 9, 2020

🎉 This PR is included in version 9.16.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Brace access syntax breaks in 9.x
2 participants