summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/ast.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/handlebars/compiler/ast.js')
-rw-r--r--lib/handlebars/compiler/ast.js41
1 files changed, 18 insertions, 23 deletions
diff --git a/lib/handlebars/compiler/ast.js b/lib/handlebars/compiler/ast.js
index 567e297..b61fa0e 100644
--- a/lib/handlebars/compiler/ast.js
+++ b/lib/handlebars/compiler/ast.js
@@ -1,15 +1,14 @@
-exports.attach = function(Handlebars) {
+import { Exception } from "../utils";
-// BEGIN(BROWSER)
-Handlebars.AST = {};
+var exports = {};
-Handlebars.AST.ProgramNode = function(statements, inverse) {
+exports.ProgramNode = function ProgramNode(statements, inverse) {
this.type = "program";
this.statements = statements;
- if(inverse) { this.inverse = new Handlebars.AST.ProgramNode(inverse); }
+ if(inverse) { this.inverse = new ProgramNode(inverse); }
};
-Handlebars.AST.MustacheNode = function(rawParams, hash, unescaped) {
+exports.MustacheNode = function(rawParams, hash, unescaped) {
this.type = "mustache";
this.escaped = !unescaped;
this.hash = hash;
@@ -31,15 +30,15 @@ Handlebars.AST.MustacheNode = function(rawParams, hash, unescaped) {
// pass or at runtime.
};
-Handlebars.AST.PartialNode = function(partialName, context) {
+exports.PartialNode = function(partialName, context) {
this.type = "partial";
this.partialName = partialName;
this.context = context;
};
-Handlebars.AST.BlockNode = function(mustache, program, inverse, close) {
+exports.BlockNode = function(mustache, program, inverse, close) {
if(mustache.id.original !== close.original) {
- throw new Handlebars.Exception(mustache.id.original + " doesn't match " + close.original);
+ throw new Exception(mustache.id.original + " doesn't match " + close.original);
}
this.type = "block";
@@ -52,17 +51,17 @@ Handlebars.AST.BlockNode = function(mustache, program, inverse, close) {
}
};
-Handlebars.AST.ContentNode = function(string) {
+exports.ContentNode = function(string) {
this.type = "content";
this.string = string;
};
-Handlebars.AST.HashNode = function(pairs) {
+exports.HashNode = function(pairs) {
this.type = "hash";
this.pairs = pairs;
};
-Handlebars.AST.IdNode = function(parts) {
+exports.IdNode = function(parts) {
this.type = "ID";
var original = "",
@@ -93,43 +92,39 @@ Handlebars.AST.IdNode = function(parts) {
this.stringModeValue = this.string;
};
-Handlebars.AST.PartialNameNode = function(name) {
+exports.PartialNameNode = function(name) {
this.type = "PARTIAL_NAME";
this.name = name.original;
};
-Handlebars.AST.DataNode = function(id) {
+exports.DataNode = function(id) {
this.type = "DATA";
this.id = id;
};
-Handlebars.AST.StringNode = function(string) {
+exports.StringNode = function(string) {
this.type = "STRING";
this.original =
this.string =
this.stringModeValue = string;
};
-Handlebars.AST.IntegerNode = function(integer) {
+exports.IntegerNode = function(integer) {
this.type = "INTEGER";
this.original =
this.integer = integer;
this.stringModeValue = Number(integer);
};
-Handlebars.AST.BooleanNode = function(bool) {
+exports.BooleanNode = function(bool) {
this.type = "BOOLEAN";
this.bool = bool;
this.stringModeValue = bool === "true";
};
-Handlebars.AST.CommentNode = function(comment) {
+exports.CommentNode = function(comment) {
this.type = "comment";
this.comment = comment;
};
-// END(BROWSER)
-
-return Handlebars;
-};
-
+export default exports;