mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Use regexp instead of isNaN for detecting integers.
This commit is contained in:
@@ -65,18 +65,20 @@ Handlebars.to_json_ast = function (code) {
|
||||
};
|
||||
|
||||
var value = function (node) {
|
||||
//Work around handlebars.js Issue #422 - Negative integers for helpers get trapped as ID
|
||||
if (node.type == 'ID' && node.string.slice(0,1) == '-' && !isNaN(node.string)) { //node.string eg. '-10'
|
||||
//Reconstruct node
|
||||
// Work around handlebars.js Issue #422 - Negative integers for
|
||||
// helpers get trapped as ID. handlebars doesn't support floating
|
||||
// point, just integers.
|
||||
if (node.type === 'ID' && /^-\d+$/.test(node.string)) {
|
||||
// Reconstruct node
|
||||
node.type = 'INTEGER';
|
||||
node.integer = node.string;
|
||||
} //EO Workaround handlebars.js Issue #422
|
||||
}
|
||||
|
||||
var choices = {
|
||||
ID: function (node) {return identifier(node);},
|
||||
STRING: function (node) {return ''+node.string;},
|
||||
INTEGER: function (node) {return +node.integer;},
|
||||
BOOLEAN: function (node) {return (node.bool === 'true');},
|
||||
BOOLEAN: function (node) {return (node.bool === 'true');}
|
||||
};
|
||||
if (!(node.type in choices))
|
||||
throw new Error("got ast node " + node.type + " for value");
|
||||
|
||||
Reference in New Issue
Block a user