Colons (:) and accented chars in id

23 views
Skip to first unread message

Carlos Noguera

unread,
Feb 8, 2016, 7:24:36 AM2/8/16
to handlebars.java
Hi all,


In handlebars.js colons and accented chars are allowed (see http://tryhandlebarsjs.com/


Template: 
Goodbye\n{{x:cruél}}\n{{world}}!

Context:
{'x:cruél': "cruel", world: "world"}

compiles to:
Goodbye\ncruel\nworld!

Handlebars.java's parser however does not allow for these chars in an identifier:

com.github.jknack.handlebars.HandlebarsException: inline@79696ab:2:1: found: '{{', expected: '<EOF>'
{{x:cruél}}
 ^
at com.github.jknack.handlebars.internal.HbsErrorReporter.syntaxError(HbsErrorReporter.java:93)
at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:65)
at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:566)
at com.github.jknack.handlebars.internal.HbsErrorStrategy.reportInputMismatch(HbsErrorStrategy.java:186)
at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:148)
at com.github.jknack.handlebars.internal.HbsParser.template(HbsParser.java:172)
....


this could be fixed by changing the lexer's rule for ID_START to include ':' and the UTF-8 range for accented characters:

ID_START
  :
   [a-zA-Z_$@:\u00C0-\u00FF]
  ;

unless I am missing something, this should not affect anything else right?


Carlos.

edgar

unread,
Feb 8, 2016, 10:20:20 AM2/8/16
to handlebars.java
Can you send a pull request?

Thanks
Reply all
Reply to author
Forward
0 new messages