summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'lib/handlebars/compiler')
-rw-r--r--lib/handlebars/compiler/ast.js56
-rw-r--r--lib/handlebars/compiler/base.js2
-rw-r--r--lib/handlebars/compiler/compiler.js12
-rw-r--r--lib/handlebars/compiler/javascript-compiler.js3
-rw-r--r--lib/handlebars/compiler/visitor.js4
5 files changed, 37 insertions, 40 deletions
diff --git a/lib/handlebars/compiler/ast.js b/lib/handlebars/compiler/ast.js
index c6c8993..e4e8049 100644
--- a/lib/handlebars/compiler/ast.js
+++ b/lib/handlebars/compiler/ast.js
@@ -1,14 +1,12 @@
import Exception from "../exception";
-var exports = {};
-
-exports.ProgramNode = function ProgramNode(statements, inverse) {
+export function ProgramNode(statements, inverse) {
this.type = "program";
this.statements = statements;
if(inverse) { this.inverse = new ProgramNode(inverse); }
-};
+}
-exports.MustacheNode = function(rawParams, hash, unescaped) {
+export function MustacheNode(rawParams, hash, unescaped) {
this.type = "mustache";
this.escaped = !unescaped;
this.hash = hash;
@@ -28,15 +26,15 @@ exports.MustacheNode = function(rawParams, hash, unescaped) {
// if a mustache is an eligible helper but not a definite
// helper, it is ambiguous, and will be resolved in a later
// pass or at runtime.
-};
+}
-exports.PartialNode = function(partialName, context) {
+export function PartialNode(partialName, context) {
this.type = "partial";
this.partialName = partialName;
this.context = context;
-};
+}
-exports.BlockNode = function(mustache, program, inverse, close) {
+export function BlockNode(mustache, program, inverse, close) {
if(mustache.id.original !== close.original) {
throw new Exception(mustache.id.original + " doesn't match " + close.original);
}
@@ -49,19 +47,19 @@ exports.BlockNode = function(mustache, program, inverse, close) {
if (this.inverse && !this.program) {
this.isInverse = true;
}
-};
+}
-exports.ContentNode = function(string) {
+export function ContentNode(string) {
this.type = "content";
this.string = string;
-};
+}
-exports.HashNode = function(pairs) {
+export function HashNode(pairs) {
this.type = "hash";
this.pairs = pairs;
-};
+}
-exports.IdNode = function(parts) {
+export function IdNode(parts) {
this.type = "ID";
var original = "",
@@ -90,41 +88,39 @@ exports.IdNode = function(parts) {
this.isSimple = parts.length === 1 && !this.isScoped && depth === 0;
this.stringModeValue = this.string;
-};
+}
-exports.PartialNameNode = function(name) {
+export function PartialNameNode(name) {
this.type = "PARTIAL_NAME";
this.name = name.original;
-};
+}
-exports.DataNode = function(id) {
+export function DataNode(id) {
this.type = "DATA";
this.id = id;
-};
+}
-exports.StringNode = function(string) {
+export function StringNode(string) {
this.type = "STRING";
this.original =
this.string =
this.stringModeValue = string;
-};
+}
-exports.IntegerNode = function(integer) {
+export function IntegerNode(integer) {
this.type = "INTEGER";
this.original =
this.integer = integer;
this.stringModeValue = Number(integer);
-};
+}
-exports.BooleanNode = function(bool) {
+export function BooleanNode(bool) {
this.type = "BOOLEAN";
this.bool = bool;
this.stringModeValue = bool === "true";
-};
+}
-exports.CommentNode = function(comment) {
+export function CommentNode(comment) {
this.type = "comment";
this.comment = comment;
-};
-
-export default exports;
+}
diff --git a/lib/handlebars/compiler/base.js b/lib/handlebars/compiler/base.js
index adbf4f2..cf4f17f 100644
--- a/lib/handlebars/compiler/base.js
+++ b/lib/handlebars/compiler/base.js
@@ -1,5 +1,5 @@
import parser from "./parser";
-import AST from "./ast";
+module AST from "./ast";
export var parser = parser;
diff --git a/lib/handlebars/compiler/compiler.js b/lib/handlebars/compiler/compiler.js
index c020e1f..0691a23 100644
--- a/lib/handlebars/compiler/compiler.js
+++ b/lib/handlebars/compiler/compiler.js
@@ -1,12 +1,10 @@
import Exception from "../exception";
import { template } from "../runtime";
import { parse } from "./base";
-import { JavaScriptCompiler } from "./javascript-compiler";
-import AST from "./ast";
+import JavaScriptCompiler from "./javascript-compiler";
+module AST from "./ast";
-/*jshint eqnull:true*/
-
-export function Compiler() {};
+export function Compiler() {}
// the foundHelper register will disambiguate helper lookup from finding a
// function in a context. This is necessary for mustache compatibility, which
@@ -428,7 +426,7 @@ export function precompile(input, options) {
var ast = parse(input);
var environment = new Compiler().compile(ast, options);
return new JavaScriptCompiler().compile(environment, options);
-};
+}
export function compile(input, options) {
if (input == null || (typeof input !== 'string' && input.constructor !== AST.ProgramNode)) {
@@ -457,4 +455,4 @@ export function compile(input, options) {
}
return compiled.call(this, context, options);
};
-};
+}
diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js
index aecef85..a81a99c 100644
--- a/lib/handlebars/compiler/javascript-compiler.js
+++ b/lib/handlebars/compiler/javascript-compiler.js
@@ -4,7 +4,7 @@ function Literal(value) {
this.value = value;
}
-export function JavaScriptCompiler() {};
+function JavaScriptCompiler() {}
JavaScriptCompiler.prototype = {
// PUBLIC API: You can override these methods in a subclass to provide
@@ -841,3 +841,4 @@ JavaScriptCompiler.isValidJavaScriptVariableName = function(name) {
return false;
};
+export default JavaScriptCompiler;
diff --git a/lib/handlebars/compiler/visitor.js b/lib/handlebars/compiler/visitor.js
index 29ea82c..6a0373e 100644
--- a/lib/handlebars/compiler/visitor.js
+++ b/lib/handlebars/compiler/visitor.js
@@ -1,4 +1,4 @@
-export function Visitor() {};
+function Visitor() {}
Visitor.prototype = {
constructor: Visitor,
@@ -7,3 +7,5 @@ Visitor.prototype = {
return this[object.type](object);
}
};
+
+export default Visitor;