-
Notifications
You must be signed in to change notification settings - Fork 71
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
The specification does not specify how to handle tags with periods in them #179
Comments
Is this really unspecified? I mean, the interpolation and section specs are rather explicit about how dotted names should be resolved. I don't think the specs allow for mustache.java's behavior. |
Well, see spullara/mustache.java#297 (comment) for their response to this issue. The behaviour is, in my opinion, undefined as there is no formal specification that I could find for what a well-formed key should be. All of the keys are alphanumeric strings with no special characters, but it doesn't say that those are the only allowed characters, which in theory permits keys of the form |
(It's worth noting that we ran into this as we were using a filename as a key, which worked as we naïvely expected in the java implementation, but then broke when we switched to a python engine) |
These are the relevant parts of the interpolation spec. The section spec has similar wording and tests. Lines 7 to 22 in 83b221a
Lines 142 to 198 in 83b221a
|
Ah, fair point, there is a description there. However, there are no tests that actually verify this. It might be good to add a test of the form - name: Dotted keys
desc: Dotted keys should not be treated as standalone keys
data:
a.b: c
template: '"{{a.b}}" == ""'
expected: '"" == ""' |
Consider the following data:
and the template
What should this render? According to the two python implementations (https://github.com/noahmorrison/chevron, https://github.com/defunkt/pystache) I have seen, it renders a blank, since
a.b
in the template is looking for a structure of the formHowever, the java implementation we use (https://github.com/spullara/mustache.java) the output instead is
In fact, the same is the case if you use input data such as
where the key
a.b
overrides the nested structure (which seems like the wrong choice to me, given the options).The problem here is that this seems to be undefined behaviour: the spec never defines what to do with keys that have periods in them, which leaves individual engines up to their own devices on how to handle it. There is an open issue which implies that one should not do this, but it is not explicit: #67 (comment)
It would be good to have this specified, to ensure consistent behaviour between various engines.
The text was updated successfully, but these errors were encountered: