-
Notifications
You must be signed in to change notification settings - Fork 124
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
templates can't process objects whose names contain non-alphanums #60
Comments
+1 for a fix |
+1 |
2 similar comments
+1 |
+1 |
+1 Would be quite handy given that we use dashes as word separators for our json field names. |
+1 |
dust templates are compiled to javascript. hence it applies the valid js identifier rules |
Veena, the fact that they get compiled to JS is an implementation strategy and not part of Dust's design, which expresses a binding from JSON objects to templates. You can accomplish the same thing compiling to key calls instead of method calls: boundObject.jsIdentifier -> boundObject['jsIdentifier'] They are functionally equivalent and probably just as fast. Alternately you can use a rule set like http://camelize.com/ to convert identifiers to something that will work as a method name. |
the complied function is it is merely a grammar artifact. Implementation of the compiler does not enforce any restrictions on the json key/reference names function() { function body_0(chk, ctx) { We probably should be able to relax it quite easily. But then we cannot support the other tokens that have special meaning in the dust grammar as identifier tokens. Looks like "-" is the only addition. "." already has a special meaning in dust. $ is supported already, since it is valid js identifier |
Steps:
Expected value in Render Result: "Hello Mick! You have 30 new messages."
Actual value in Render Result: "Hello {first-name}! You have 30 new messages."
Please consult json.org for valid field identifiers. It allows a whole lot more than most people realize.
The text was updated successfully, but these errors were encountered: