Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Non-integer numeric parameters aren't supported #573

@dontgitit

Description

@dontgitit

Handlebars added numeric support in v2.0: handlebars-lang/handlebars.js#472

HbsLexer.g4 still supports only integers: https://github.com/jknack/handlebars.java/blob/master/handlebars/src/main/antlr4/com/github/jknack/handlebars/internal/HbsLexer.g4#L283

It should probably be changed to match the pattern that handlebars uses: handlebars-lang/handlebars.js@d4cfe90#diff-a13581e6dfc1c61c90703da188230cbcR80

Any code that has a declared decimal parameter fails, i.e.
{{#if 1.5}}{{/if}}

fails with

com.github.jknack.handlebars.HandlebarsException: inline@20a72c8c:1:6: found: '1.5', expected: '}}'
{{#if 1.5}}{{/if}}
      ^
	at com.github.jknack.handlebars.internal.HbsErrorReporter.syntaxError(HbsErrorReporter.java:93) ~[handlebars-4.0.5.jar:na]
	at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:65) ~[antlr4-runtime-4.5.1-1.jar:4.5.1-1]
	at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:566) ~[antlr4-runtime-4.5.1-1.jar:4.5.1-1]
	at com.github.jknack.handlebars.internal.HbsErrorStrategy.reportInputMismatch(HbsErrorStrategy.java:186) ~[handlebars-4.0.5.jar:na]
	at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:148) ~[antlr4-runtime-4.5.1-1.jar:4.5.1-1]

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions