diff options
Diffstat (limited to 'lib/handlebars/compiler/ast.js')
-rw-r--r-- | lib/handlebars/compiler/ast.js | 56 |
1 files changed, 26 insertions, 30 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; +} |