Whitespace
This commit is contained in:
+20
-20
@@ -5,7 +5,7 @@ var Handlebars = {
|
||||
if (Handlebars.compilerCache[string] == null) {
|
||||
var fnBody = Handlebars.compileFunctionBody(string);
|
||||
var fn = new Function("context", "fallback", "stack", "Handlebars", fnBody);
|
||||
Handlebars.compilerCache[string] =
|
||||
Handlebars.compilerCache[string] =
|
||||
function(context, fallback, stack) { return fn(context, fallback, stack, Handlebars); };
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ var Handlebars = {
|
||||
var fnBody = Handlebars.compileFunctionBody(string);
|
||||
return "function(context, fallback, stack) { " + fnBody + "}";
|
||||
},
|
||||
|
||||
|
||||
compileFunctionBody: function(string) {
|
||||
var compiler = new Handlebars.Compiler(string);
|
||||
compiler.compile();
|
||||
@@ -29,7 +29,7 @@ var Handlebars = {
|
||||
},
|
||||
|
||||
trim: function(str) {
|
||||
return str.replace(/^\s+|\s+$/g, '');
|
||||
return str.replace(/^\s+|\s+$/g, '');
|
||||
},
|
||||
|
||||
escapeText: function(string) {
|
||||
@@ -75,13 +75,13 @@ var Handlebars = {
|
||||
} else {
|
||||
compiled = Handlebars.compile(partial);
|
||||
}
|
||||
|
||||
|
||||
return compiled;
|
||||
},
|
||||
|
||||
evalExpression: function(path, context, stack, fallback) {
|
||||
fallback = fallback || {};
|
||||
|
||||
|
||||
var parsedPath = Handlebars.parsePath(path);
|
||||
var depth = parsedPath[0];
|
||||
var parts = parsedPath[1];
|
||||
@@ -94,16 +94,16 @@ var Handlebars = {
|
||||
for (var i = 0; i < parts.length && typeof context !== "undefined" && context != null ; i++) {
|
||||
context = context[parts[i]];
|
||||
}
|
||||
|
||||
|
||||
if (parts.length == 1 && typeof context === "undefined") {
|
||||
return fallback[parts[0]];
|
||||
}
|
||||
|
||||
|
||||
return context;
|
||||
},
|
||||
|
||||
buildContext: function(context, stack) {
|
||||
var ContextWrapper = function(stack) {
|
||||
var ContextWrapper = function(stack) {
|
||||
this.__stack__ = stack.slice(0);
|
||||
this.__get__ = function(path) {
|
||||
return Handlebars.evalExpression(path, this, this.__stack__);
|
||||
@@ -136,7 +136,7 @@ var Handlebars = {
|
||||
switch(parts[i]) {
|
||||
case "..":
|
||||
if (readDepth) {
|
||||
throw new Handlebars.Exception("Cannot jump out of context after moving into a context.");
|
||||
throw new Handlebars.Exception("Cannot jump out of context after moving into a context.");
|
||||
} else {
|
||||
depth += 1;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ var Handlebars = {
|
||||
dig.push(parts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var ret = [depth, dig];
|
||||
Handlebars.pathPatterns["hbs" + path] = ret;
|
||||
return ret;
|
||||
@@ -173,11 +173,11 @@ var Handlebars = {
|
||||
|
||||
// Escapes output and converts empty values to empty strings
|
||||
filterOutput: function(value, escape) {
|
||||
|
||||
|
||||
if (Handlebars.isEmpty(value)) {
|
||||
return "";
|
||||
} else if (escape) {
|
||||
return Handlebars.escapeExpression(value);
|
||||
return Handlebars.escapeExpression(value);
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
@@ -188,19 +188,19 @@ var Handlebars = {
|
||||
if (Handlebars.isFunction(lookup)) {
|
||||
out = out + lookup.call(context, arg, fn);
|
||||
if (notFn != null && Handlebars.isFunction(lookup.not)) {
|
||||
out = out + lookup.not.call(context, arg, notFn);
|
||||
}
|
||||
out = out + lookup.not.call(context, arg, notFn);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!Handlebars.isEmpty(lookup)) {
|
||||
out = out + Handlebars.helperMissing.call(arg, lookup, fn);
|
||||
}
|
||||
|
||||
|
||||
if (notFn != null) {
|
||||
out = out + Handlebars.helperMissing.not.call(arg, lookup, notFn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return out;
|
||||
},
|
||||
|
||||
@@ -334,7 +334,7 @@ Handlebars.Compiler.prototype = {
|
||||
},
|
||||
|
||||
addExpression: function(mustache, param) {
|
||||
param = param || null;
|
||||
param = param || null;
|
||||
var expr = this.lookupFor(mustache);
|
||||
this.fn += "var proxy = Handlebars.buildContext(context, stack);"
|
||||
this.fn += "out = out + Handlebars.handleExpression(" + expr + ", proxy, " + param + ", " + this.escaped + ");";
|
||||
@@ -343,7 +343,7 @@ Handlebars.Compiler.prototype = {
|
||||
addInvertedSection: function(mustache) {
|
||||
var compiler = this.compileToEndOfBlock(mustache);
|
||||
var result = compiler.fn;
|
||||
|
||||
|
||||
// each function made internally needs a unique IDs. These are locals, so they
|
||||
// don't need to be globally unique, just per compiler
|
||||
var fnId = "fn" + this.pointer.toString();
|
||||
@@ -413,7 +413,7 @@ Handlebars.Compiler.prototype = {
|
||||
|
||||
addPartial: function(mustache, param) {
|
||||
// either used a cached copy of the partial or compile a new one
|
||||
this.fn += "if (typeof fallback['partials'] === 'undefined' || typeof fallback['partials']['" + mustache + "'] === 'undefined') throw new Handlebars.Exception('Attempted to render undefined partial: " + mustache + "');";
|
||||
this.fn += "if (typeof fallback['partials'] === 'undefined' || typeof fallback['partials']['" + mustache + "'] === 'undefined') throw new Handlebars.Exception('Attempted to render undefined partial: " + mustache + "');";
|
||||
this.fn += "out = out + Handlebars.compilePartial(fallback['partials']['" + mustache + "'])(" + param + ", fallback, stack);";
|
||||
},
|
||||
|
||||
@@ -453,7 +453,7 @@ Handlebars.Compiler.prototype = {
|
||||
|
||||
// finish reading off the close of the handlebars
|
||||
this.getChar();
|
||||
// {{{expression}} is techically valid, but if we started with {{{ we'll try to read
|
||||
// {{{expression}} is techically valid, but if we started with {{{ we'll try to read
|
||||
// }}} off of the close of the handlebars
|
||||
if (!this.escaped && this.peek() === "}") {
|
||||
this.getChar();
|
||||
|
||||
Reference in New Issue
Block a user