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

Mustache engine handles possibly invalid keynames in possibly incorrect way #297

Open
simon-ess opened this issue Nov 21, 2023 · 1 comment

Comments

@simon-ess
Copy link

See mustache/spec#179 for an issue raised on the mustache spec repository.

In brief, mustache.java renders the input data

{ "a.b": "c" }

and template

{{ a.b }}

as

c

which is in a perhaps-incorrect way, although one that is not actually specified by the spec. It is likely that keys are never intended to have periods in them (see mustache/spec#67 (comment)), but again, this is not actually specified.

Note that other engines, such as both of the python ones I have checked, render this as a blank.

Note further that the current java engine prioritises a key with a period over nested data: that is, the following data renders probably incorrectly (though again, not actually counter to the specification):

{ "a": { "b": "expected"}, "a.b": "c" }

and

{{ a.b }}

render as

c

which is not what I would expect.

@spullara
Copy link
Owner

I think we are in unspecified behavior land. I shouldn't change the way this works as it would be backward incompatible. Seems like an edge case. If you absolutely need to have it work differently it would be straight-forward to override the ObjectHandler. Override findWrapper with a method that returns null if the name has a . in it.

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

No branches or pull requests

2 participants