-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
Helper arguments starting with a number are split in two parts #450
Comments
it seems the underscore separator in number literal is a new feature introduced recently and is not supported by some json parsers and handlebarsjs language. We will hold the support for now. However as you found out, there is issue with our parser when parsing parameters of helpers. This is also related to #443 . I will attempt to fix it in future. |
Thank yo for your reply. To be clear, I am not expecting the number to be parsed correctly (although in my case of rendering TOML, it would make my life easier 😃). I managed to work around the problem by passing a constant string From what I tested with HandlebarsJS it would render the context variable if it exists, which is also what handlebars-rust would do without invoking a helper. I tested the following template rendered with a context
With the original JS handlebars, I get:
With handlebars-rust, I get:
So I guess the right thing to in this case is to try to resolve the "number" as a variable name (even if having such variable names is a bit silly), and fail or not depending on the strict mode. |
These test cases capture the issue called out in sunng87#450. The handling of identifiers which start with numbers diverges from the official JavaScript implementation of Handlebars. It's especially bad for cases like `{{eq 1a}}`, which validly parses as `{{eq 1 a}}`!
These test cases capture the issue called out in sunng87#450. The handling of identifiers which start with numbers diverges from the official JavaScript implementation of Handlebars. It's especially bad for cases like `{{eq 1a}}`, which validly parses as `{{eq 1 a}}`!
When a helper parameter starts with a number, but contain something else after, it will be split at the first non-digit character.
For example
{{helper 100_000}}
will result in an agument sequence of[PathAndJson { relative_path: None, value: Constant(Number(100)) }, PathAndJson { relative_path: Some("_000"), value: Missing }]
I would expect one of:
"100_000"
100000
But truncating here seems like a bug.
Full example:
Output with handlebars-rust 4.0.1:
The text was updated successfully, but these errors were encountered: