summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/runtime.js
diff options
context:
space:
mode:
authorwycats <wycats@gmail.com>2010-12-04 22:26:23 -0500
committerwycats <wycats@gmail.com>2010-12-04 22:26:41 -0500
commit35b4d9fd01c850eab74f80fd5672a66abda81ea5 (patch)
treee9d139812b2398d2ebef200e0baa4dcb9b2e3344 /lib/handlebars/runtime.js
parent4db1abcd742e2044a0c745692fe90dfe71e6c74d (diff)
downloadhandlebars.js-35b4d9fd01c850eab74f80fd5672a66abda81ea5.zip
handlebars.js-35b4d9fd01c850eab74f80fd5672a66abda81ea5.tar.gz
handlebars.js-35b4d9fd01c850eab74f80fd5672a66abda81ea5.tar.bz2
linting
Diffstat (limited to 'lib/handlebars/runtime.js')
-rw-r--r--lib/handlebars/runtime.js27
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/handlebars/runtime.js b/lib/handlebars/runtime.js
index ac4bc0b..75b9d9a 100644
--- a/lib/handlebars/runtime.js
+++ b/lib/handlebars/runtime.js
@@ -67,7 +67,7 @@ Handlebars.proxy = function(obj) {
var Proxy = this.K;
Proxy.prototype = obj;
return new Proxy();
-}
+};
Handlebars.Runtime = function(context, fallback, stack) {
this.stack = stack || [];
@@ -125,7 +125,7 @@ Handlebars.Runtime.prototype = {
if(buf && mustache.escaped) { buf = Handlebars.Utils.escapeExpression(buf); }
- this.buffer = this.buffer + ((buf == null || buf === false) ? '' : buf);
+ this.buffer = this.buffer + ((!buf && buf !== 0) ? '' : buf);
},
block: function(block) {
@@ -135,6 +135,8 @@ Handlebars.Runtime.prototype = {
var idObj = this.ID(mustache.id),
data = idObj.data;
+ var result;
+
if(toString.call(data) !== "[object Function]") {
params = [data];
data = this.context.fallback.helperMissing;
@@ -143,13 +145,13 @@ Handlebars.Runtime.prototype = {
}
params.push(this.wrapProgram(block.program));
- var result = data.apply(this.wrapContext(), params);
+ result = data.apply(this.wrapContext(), params);
this.buffer = this.buffer + result;
if(block.program.inverse) {
params.pop();
params.push(this.wrapProgram(block.program.inverse));
- var result = data.not.apply(this.wrapContext(), params);
+ result = data.not.apply(this.wrapContext(), params);
this.buffer = this.buffer + result;
}
},
@@ -159,22 +161,23 @@ Handlebars.Runtime.prototype = {
var id = partial.id.original;
var partialBody = partials[partial.id.original];
+ var program, context;
if(!partialBody) {
throw new Handlebars.Exception("The partial " + partial.id.original + " does not exist");
}
if(typeof partialBody === "string") {
- var program = Handlebars.parse(partialBody);
+ program = Handlebars.parse(partialBody);
partials[id] = program;
} else {
program = partialBody;
}
if(partial.context) {
- var context = this.ID(partial.context);
+ context = this.ID(partial.context);
} else {
- var context = this.context;
+ context = this.context;
}
var runtime = new Handlebars.Runtime(context, this.context.fallback, this.stack.slice(0));
this.buffer = this.buffer + runtime.program(program);
@@ -202,8 +205,8 @@ Handlebars.Runtime.prototype = {
id = id.parts.join("/");
data = data.apply(context, params);
- if(Handlebars.Utils.isEmpty(data)) { isInverse = true }
- if(data.not) { not = data.not } else { not = this.not }
+ if(Handlebars.Utils.isEmpty(data)) { isInverse = true; }
+ if(data.not) { not = data.not; } else { not = this.not; }
} else {
not = this.not;
}
@@ -239,7 +242,7 @@ Handlebars.Runtime.prototype = {
proxy.__get__ = function(path) {
path = new Handlebars.AST.IdNode(path.split("/"));
- return context.evaluate(path, stack).data
+ return context.evaluate(path, stack).data;
};
proxy.isWrappedContext = true;
@@ -258,10 +261,10 @@ Handlebars.Runtime.prototype = {
var runtime = new Handlebars.Runtime(context, fallback, stack);
runtime.program(program);
return runtime.buffer;
- }
+ };
}
-}
+};
// END(BROWSER)
exports.Runtime = Handlebars.Runtime;