Download Handlebars.js v.1.0.11 or above.
The github bug report was recently answered. The fix was to replace the alpha-numeric regex:
[a-zA-Z0-9_$:-]
into unicode complient regex:
[^\s!"#%-,./;->@[-\^`{-~]
Question
I'am using handlebars.js and JSON data to fill my HTML. My test fail if I call a JSON key which is a CJK unicode character. Is there any workaround to successfully process (CJK) unicode keys with handlebars.js ?
This works [1]:
var source2 = '<p>{{blatitle}}<br />{{bla.zht}}} / {{bla.pyn}} / {{bla.dfn}}</p>';
var template = Handlebars.compile(source2);
var html = template(jsonDictSample);
$('#container2')
.append(html);
This doesn't works (case duplication, only change key 'bla' into unicode '口' as key) [1]:
var source3 = '<p>{{title}}<br />{{口.zht}} / {{口.pyn}} / {{口.dfn}}</p>';
var template = Handlebars.compile(source3);
var html = template(jsonDictSample);
$('#container3')
.append(html);
Note1: I know I can convert to and use "u53E3" for the unicode character "口", but I want to keep my JSON with CJK unicode characters such "口".
Note2 - Mustache works: CJK unicode keys works with Mustache.js [2], so it's not JSON issue, but an handlebars.js issue. Since I need advanced function, I am still looking for a Handlebars solution.
[1]: http://jsfiddle.net/YqhKG/ -- handlebar test: fail.
[2]: note -- mustache.js test: works fine.
Thanks in advance.
Solution
Download Handlebars.js v.1.0.11 or above.
The github bug report was recently answered. The fix was to replace the alpha-numeric regex:
[a-zA-Z0-9_$:-]
into unicode complient regex:
[^\s!"#%-,./;->@[-\^`{-~]