summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/handlebars/compiler.js')
-rw-r--r--lib/handlebars/compiler.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/handlebars/compiler.js b/lib/handlebars/compiler.js
index 96ae36a..2ffd829 100644
--- a/lib/handlebars/compiler.js
+++ b/lib/handlebars/compiler.js
@@ -77,6 +77,28 @@ Handlebars.registerHelper('blockHelperMissing', function(context, fn, inverse) {
}, function(context, fn) {
return fn(context)
});
+
+Handlebars.registerHelper('each', function(context, fn, inverse) {
+ var ret = "";
+
+ if(context.length > 0) {
+ for(var i=0, j=context.length; i<j; i++) {
+ ret = ret + fn(context[i]);
+ }
+ } else {
+ ret = inverse(this);
+ }
+ return ret;
+});
+
+Handlebars.registerHelper('if', function(context, fn, inverse) {
+ if(context === false || context == null) {
+ return inverse(this);
+ } else {
+ return fn(this);
+ }
+});
+
// END(BROWSER)
exports.Handlebars = Handlebars;