changeset 26:8535d63dc1c1

Added `ifnot` Handlebar helper.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 05 Jan 2013 11:52:34 -0800
parents 161a0f534201
children a42bd59bbe6f
files wikked/static/js/wikked/handlebars.js
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/wikked/static/js/wikked/handlebars.js	Fri Jan 04 19:36:08 2013 -0800
+++ b/wikked/static/js/wikked/handlebars.js	Sat Jan 05 11:52:34 2013 -0800
@@ -45,6 +45,19 @@
         return options.inverse(this);
     });
 
+    /**
+     * Inverse if.
+     */
+    Handlebars.registerHelper('ifnot', function(context, options) {
+        if (!context) {
+            return options.fn(this);
+        }
+        return options.inverse(this);
+    });
+
+    /**
+     * Format dates.
+     */
     Handlebars.registerHelper('date', function(timestamp) {
         var date = new Date(timestamp * 1000);
         return date.toDateString();