Skip to content

Conversation

@reteps
Copy link

@reteps reteps commented Apr 19, 2025

I have templates with .0 attribute accesses I want to be able to parse. This is a common idea in mustache.
https://stackoverflow.com/a/17837909/5684541

@NullVoxPopuli
Copy link
Contributor

How do you handle this object?

{
  "0.foo": 2
}

@reteps
Copy link
Author

reteps commented Apr 20, 2025

Hi @NullVoxPopuli, I tried doing this in the Bison/Yacc grammar, but I couldn't find a clean way to do this. So I explicitly disallow it in preparePath. I added this in a5fca87.

@NullVoxPopuli
Copy link
Contributor

Neat, how about this situation:

{
  "0.foo": 2
  0: {
    foo: 3
  }
}

How would you get either of those?

@reteps
Copy link
Author

reteps commented Apr 20, 2025

I think that behavior is consistent with the existing design (how would "bar.foo" as a key of a object work right now?). The second case should work with this new implementation. (assuming these aren't top level objects but rather "this.0.foo")

@reteps
Copy link
Author

reteps commented Apr 20, 2025

I would be happy to change the behavior to whatever you expect though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants