Initial work on ES6 modules

This commit is contained in:
Yehuda Katz
2013-07-01 13:59:58 -07:00
parent 8e2416dabb
commit 88ee4757e7
15 changed files with 453 additions and 400 deletions
+15 -24
View File
@@ -1,15 +1,12 @@
exports.attach = function(Handlebars) {
import { Exception } from "handlebars/utils";
// BEGIN(BROWSER)
Handlebars.AST = {};
Handlebars.AST.ProgramNode = function(statements, inverse) {
export function ProgramNode(statements, inverse) {
this.type = "program";
this.statements = statements;
if(inverse) { this.inverse = new Handlebars.AST.ProgramNode(inverse); }
};
Handlebars.AST.MustacheNode = function(rawParams, hash, unescaped) {
export function MustacheNode(rawParams, hash, unescaped) {
this.type = "mustache";
this.escaped = !unescaped;
this.hash = hash;
@@ -31,15 +28,15 @@ Handlebars.AST.MustacheNode = function(rawParams, hash, unescaped) {
// pass or at runtime.
};
Handlebars.AST.PartialNode = function(partialName, context) {
export function PartialNode(partialName, context) {
this.type = "partial";
this.partialName = partialName;
this.context = context;
};
Handlebars.AST.BlockNode = function(mustache, program, inverse, close) {
export function BlockNode(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 +49,17 @@ Handlebars.AST.BlockNode = function(mustache, program, inverse, close) {
}
};
Handlebars.AST.ContentNode = function(string) {
export function ContentNode(string) {
this.type = "content";
this.string = string;
};
Handlebars.AST.HashNode = function(pairs) {
export function HashNode(pairs) {
this.type = "hash";
this.pairs = pairs;
};
Handlebars.AST.IdNode = function(parts) {
export function IdNode(part) {
this.type = "ID";
var original = "",
@@ -93,43 +90,37 @@ Handlebars.AST.IdNode = function(parts) {
this.stringModeValue = this.string;
};
Handlebars.AST.PartialNameNode = function(name) {
export function PartialNameNode(name) {
this.type = "PARTIAL_NAME";
this.name = name.original;
};
Handlebars.AST.DataNode = function(id) {
export function DataNode(id) {
this.type = "DATA";
this.id = id;
};
Handlebars.AST.StringNode = function(string) {
export function StringNode(string) {
this.type = "STRING";
this.original =
this.string =
this.stringModeValue = string;
};
Handlebars.AST.IntegerNode = function(integer) {
export function IntegerNode(integer) {
this.type = "INTEGER";
this.original =
this.integer = integer;
this.stringModeValue = Number(integer);
};
Handlebars.AST.BooleanNode = function(bool) {
export function BooleanNode(bool) {
this.type = "BOOLEAN";
this.bool = bool;
this.stringModeValue = bool === "true";
};
Handlebars.AST.CommentNode = function(comment) {
export function CommentNode(comment) {
this.type = "comment";
this.comment = comment;
};
// END(BROWSER)
return Handlebars;
};