summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2014-11-26 19:22:09 -0600
committerkpdecker <kpdecker@gmail.com>2014-11-26 19:22:09 -0600
commit697bbe59cad06bc74a945f7e26fc0af333a01d47 (patch)
tree9d51923ba37e8960c371c67db181d33fdf63bf29 /lib/handlebars/compiler
parent2a4819d75cba7513946af5cf28ee22881561814f (diff)
downloadhandlebars.js-697bbe59cad06bc74a945f7e26fc0af333a01d47.zip
handlebars.js-697bbe59cad06bc74a945f7e26fc0af333a01d47.tar.gz
handlebars.js-697bbe59cad06bc74a945f7e26fc0af333a01d47.tar.bz2
Update literal ast nodes for new spec
Diffstat (limited to 'lib/handlebars/compiler')
-rw-r--r--lib/handlebars/compiler/ast.js15
-rw-r--r--lib/handlebars/compiler/code-gen.js2
-rw-r--r--lib/handlebars/compiler/compiler.js14
-rw-r--r--lib/handlebars/compiler/printer.js12
-rw-r--r--lib/handlebars/compiler/visitor.js6
5 files changed, 23 insertions, 26 deletions
diff --git a/lib/handlebars/compiler/ast.js b/lib/handlebars/compiler/ast.js
index 26ea4ab..44b26ec 100644
--- a/lib/handlebars/compiler/ast.js
+++ b/lib/handlebars/compiler/ast.js
@@ -142,25 +142,22 @@ var AST = {
StringNode: function(string, locInfo) {
this.loc = locInfo;
- this.type = "STRING";
+ this.type = 'StringLiteral';
this.original =
- this.string =
- this.stringModeValue = string;
+ this.value = string;
},
NumberNode: function(number, locInfo) {
this.loc = locInfo;
- this.type = "NUMBER";
+ this.type = 'NumberLiteral';
this.original =
- this.number = number;
- this.stringModeValue = Number(number);
+ this.value = Number(number);
},
BooleanNode: function(bool, locInfo) {
this.loc = locInfo;
- this.type = "BOOLEAN";
- this.bool = bool;
- this.stringModeValue = bool === "true";
+ this.type = 'BooleanLiteral';
+ this.value = bool === 'true';
}
};
diff --git a/lib/handlebars/compiler/code-gen.js b/lib/handlebars/compiler/code-gen.js
index 30f0735..a7c1659 100644
--- a/lib/handlebars/compiler/code-gen.js
+++ b/lib/handlebars/compiler/code-gen.js
@@ -99,7 +99,7 @@ CodeGen.prototype = {
},
quotedString: function(str) {
- return '"' + str
+ return '"' + (str + '')
.replace(/\\/g, '\\\\')
.replace(/"/g, '\\"')
.replace(/\n/g, '\\n')
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js
index ea2272a..a5acb64 100644
--- a/lib/handlebars/compiler/compiler.js
+++ b/lib/handlebars/compiler/compiler.js
@@ -283,16 +283,16 @@ Compiler.prototype = {
this.opcode('lookupData', data, data.id.depth, data.id.parts);
},
- STRING: function(string) {
- this.opcode('pushString', string, string.string);
+ StringLiteral: function(string) {
+ this.opcode('pushString', string, string.value);
},
- NUMBER: function(number) {
- this.opcode('pushLiteral', number, number.number);
+ NumberLiteral: function(number) {
+ this.opcode('pushLiteral', number, number.value);
},
- BOOLEAN: function(bool) {
- this.opcode('pushLiteral', bool, bool.bool);
+ BooleanLiteral: function(bool) {
+ this.opcode('pushLiteral', bool, bool.value);
},
// HELPERS
@@ -338,7 +338,7 @@ Compiler.prototype = {
},
pushParam: function(val) {
- var stringModeValue = val.stringModeValue != null ? val.stringModeValue : '';
+ var stringModeValue = val.stringModeValue || (val.value != null ? val.value : '');
if (this.stringParams) {
if(val.depth) {
diff --git a/lib/handlebars/compiler/printer.js b/lib/handlebars/compiler/printer.js
index dac8ec2..c86f7fa 100644
--- a/lib/handlebars/compiler/printer.js
+++ b/lib/handlebars/compiler/printer.js
@@ -120,16 +120,16 @@ PrintVisitor.prototype.hash = function(hash) {
return "HASH{" + joinedPairs.join(", ") + "}";
};
-PrintVisitor.prototype.STRING = function(string) {
- return '"' + string.string + '"';
+PrintVisitor.prototype.StringLiteral = function(string) {
+ return '"' + string.value + '"';
};
-PrintVisitor.prototype.NUMBER = function(number) {
- return "NUMBER{" + number.number + "}";
+PrintVisitor.prototype.NumberLiteral = function(number) {
+ return "NUMBER{" + number.value + "}";
};
-PrintVisitor.prototype.BOOLEAN = function(bool) {
- return "BOOLEAN{" + bool.bool + "}";
+PrintVisitor.prototype.BooleanLiteral = function(bool) {
+ return "BOOLEAN{" + bool.value + "}";
};
PrintVisitor.prototype.ID = function(id) {
diff --git a/lib/handlebars/compiler/visitor.js b/lib/handlebars/compiler/visitor.js
index e48c9bc..a2ad7bb 100644
--- a/lib/handlebars/compiler/visitor.js
+++ b/lib/handlebars/compiler/visitor.js
@@ -57,9 +57,9 @@ Visitor.prototype = {
this.accept(data.id);
},
- STRING: function(string) {},
- NUMBER: function(number) {},
- BOOLEAN: function(bool) {},
+ StringLiteral: function(string) {},
+ NumberLiteral: function(number) {},
+ BooleanLiteral: function(bool) {},
ID: function(id) {}
};