Skip to content

Commit

Permalink
Import Handlebars @ v1.0.10
Browse files Browse the repository at this point in the history
Updates Handlebars to the latest published [to npm] version.

**Note:** `Handlebars.VERSION` still reports "1.0.0-rc.3".
  • Loading branch information
ericf committed Mar 22, 2013
1 parent c4cd930 commit 8a4fc07
Show file tree
Hide file tree
Showing 7 changed files with 1,204 additions and 1,213 deletions.
15 changes: 1 addition & 14 deletions src/handlebars/js/handlebars-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

// BEGIN(BROWSER)

/*jshint eqnull:true*/
var Handlebars = {};

(function(Handlebars) {

Handlebars.VERSION = "1.0.0-rc.3";
Handlebars.COMPILER_REVISION = 2;

Expand Down Expand Up @@ -40,8 +35,6 @@ var toString = Object.prototype.toString, functionType = "[object Function]";
Handlebars.registerHelper('blockHelperMissing', function(context, options) {
var inverse = options.inverse || function() {}, fn = options.fn;


var ret = "";
var type = toString.call(context);

if(type === functionType) { context = context.call(this); }
Expand Down Expand Up @@ -132,11 +125,7 @@ Handlebars.registerHelper('if', function(context, options) {
});

Handlebars.registerHelper('unless', function(context, options) {
var fn = options.fn, inverse = options.inverse;
options.fn = inverse;
options.inverse = fn;

return Handlebars.helpers['if'].call(this, context, options);
return Handlebars.helpers['if'].call(this, context, {fn: options.inverse, inverse: options.fn});
});

Handlebars.registerHelper('with', function(context, options) {
Expand All @@ -148,6 +137,4 @@ Handlebars.registerHelper('log', function(context, options) {
Handlebars.log(level, context);
});

}(Handlebars));

// END(BROWSER)
223 changes: 110 additions & 113 deletions src/handlebars/js/handlebars-compiler-ast.js
Original file line number Diff line number Diff line change
@@ -1,132 +1,129 @@
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */

// BEGIN(BROWSER)
(function() {

Handlebars.AST = {};

Handlebars.AST.ProgramNode = function(statements, inverse) {
this.type = "program";
this.statements = statements;
if(inverse) { this.inverse = new Handlebars.AST.ProgramNode(inverse); }
};

Handlebars.AST.MustacheNode = function(rawParams, hash, unescaped) {
this.type = "mustache";
this.escaped = !unescaped;
this.hash = hash;

var id = this.id = rawParams[0];
var params = this.params = rawParams.slice(1);

// a mustache is an eligible helper if:
// * its id is simple (a single part, not `this` or `..`)
var eligibleHelper = this.eligibleHelper = id.isSimple;

// a mustache is definitely a helper if:
// * it is an eligible helper, and
// * it has at least one parameter or hash segment
this.isHelper = eligibleHelper && (params.length || hash);

// 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.
};

Handlebars.AST.PartialNode = function(partialName, context) {
this.type = "partial";
this.partialName = partialName;
this.context = context;
};

Handlebars.AST = {};

Handlebars.AST.ProgramNode = function(statements, inverse) {
this.type = "program";
this.statements = statements;
if(inverse) { this.inverse = new Handlebars.AST.ProgramNode(inverse); }
};

Handlebars.AST.MustacheNode = function(rawParams, hash, unescaped) {
this.type = "mustache";
this.escaped = !unescaped;
this.hash = hash;

var id = this.id = rawParams[0];
var params = this.params = rawParams.slice(1);

// a mustache is an eligible helper if:
// * its id is simple (a single part, not `this` or `..`)
var eligibleHelper = this.eligibleHelper = id.isSimple;

// a mustache is definitely a helper if:
// * it is an eligible helper, and
// * it has at least one parameter or hash segment
this.isHelper = eligibleHelper && (params.length || hash);

// 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.
};

Handlebars.AST.PartialNode = function(partialName, context) {
this.type = "partial";
this.partialName = partialName;
this.context = context;
};

Handlebars.AST.BlockNode = function(mustache, program, inverse, close) {
var verifyMatch = function(open, close) {
if(open.original !== close.original) {
throw new Handlebars.Exception(open.original + " doesn't match " + close.original);
}
};

Handlebars.AST.BlockNode = function(mustache, program, inverse, close) {
verifyMatch(mustache.id, close);
this.type = "block";
this.mustache = mustache;
this.program = program;
this.inverse = inverse;
verifyMatch(mustache.id, close);
this.type = "block";
this.mustache = mustache;
this.program = program;
this.inverse = inverse;

if (this.inverse && !this.program) {
this.isInverse = true;
}
};
if (this.inverse && !this.program) {
this.isInverse = true;
}
};

Handlebars.AST.ContentNode = function(string) {
this.type = "content";
this.string = string;
};
Handlebars.AST.ContentNode = function(string) {
this.type = "content";
this.string = string;
};

Handlebars.AST.HashNode = function(pairs) {
this.type = "hash";
this.pairs = pairs;
};
Handlebars.AST.HashNode = function(pairs) {
this.type = "hash";
this.pairs = pairs;
};

Handlebars.AST.IdNode = function(parts) {
this.type = "ID";
this.original = parts.join(".");
Handlebars.AST.IdNode = function(parts) {
this.type = "ID";
this.original = parts.join(".");

var dig = [], depth = 0;
var dig = [], depth = 0;

for(var i=0,l=parts.length; i<l; i++) {
var part = parts[i];
for(var i=0,l=parts.length; i<l; i++) {
var part = parts[i];

if (part === ".." || part === "." || part === "this") {
if (dig.length > 0) { throw new Handlebars.Exception("Invalid path: " + this.original); }
else if (part === "..") { depth++; }
else { this.isScoped = true; }
}
else { dig.push(part); }
if (part === ".." || part === "." || part === "this") {
if (dig.length > 0) { throw new Handlebars.Exception("Invalid path: " + this.original); }
else if (part === "..") { depth++; }
else { this.isScoped = true; }
}
else { dig.push(part); }
}

this.parts = dig;
this.string = dig.join('.');
this.depth = depth;

// an ID is simple if it only has one part, and that part is not
// `..` or `this`.
this.isSimple = parts.length === 1 && !this.isScoped && depth === 0;

this.stringModeValue = this.string;
};

Handlebars.AST.PartialNameNode = function(name) {
this.type = "PARTIAL_NAME";
this.name = name;
};

Handlebars.AST.DataNode = function(id) {
this.type = "DATA";
this.id = id;
};

Handlebars.AST.StringNode = function(string) {
this.type = "STRING";
this.string = string;
this.stringModeValue = string;
};

Handlebars.AST.IntegerNode = function(integer) {
this.type = "INTEGER";
this.integer = integer;
this.stringModeValue = Number(integer);
};

Handlebars.AST.BooleanNode = function(bool) {
this.type = "BOOLEAN";
this.bool = bool;
this.stringModeValue = bool === "true";
};

Handlebars.AST.CommentNode = function(comment) {
this.type = "comment";
this.comment = comment;
};

this.parts = dig;
this.string = dig.join('.');
this.depth = depth;

// an ID is simple if it only has one part, and that part is not
// `..` or `this`.
this.isSimple = parts.length === 1 && !this.isScoped && depth === 0;

this.stringModeValue = this.string;
};

Handlebars.AST.PartialNameNode = function(name) {
this.type = "PARTIAL_NAME";
this.name = name;
};

Handlebars.AST.DataNode = function(id) {
this.type = "DATA";
this.id = id;
};

Handlebars.AST.StringNode = function(string) {
this.type = "STRING";
this.string = string;
this.stringModeValue = string;
};

Handlebars.AST.IntegerNode = function(integer) {
this.type = "INTEGER";
this.integer = integer;
this.stringModeValue = Number(integer);
};

Handlebars.AST.BooleanNode = function(bool) {
this.type = "BOOLEAN";
this.bool = bool;
this.stringModeValue = bool === "true";
};

Handlebars.AST.CommentNode = function(comment) {
this.type = "comment";
this.comment = comment;
};

})();
// END(BROWSER)
4 changes: 1 addition & 3 deletions src/handlebars/js/handlebars-compiler-base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* THIS FILE IS GENERATED BY A BUILD SCRIPT - DO NOT EDIT! */

// BEGIN(BROWSER)

Handlebars.Parser = handlebars;

Handlebars.parse = function(input) {
Expand All @@ -12,7 +13,4 @@ Handlebars.parse = function(input) {
return Handlebars.Parser.parse(input);
};

Handlebars.print = function(ast) {
return new Handlebars.PrintVisitor().accept(ast);
};
// END(BROWSER)
Loading

0 comments on commit 8a4fc07

Please sign in to comment.