From b0bc71cd66fa06632e938f4e74c802e4b7aab2f1 Mon Sep 17 00:00:00 2001 From: hacksalot Date: Fri, 18 Dec 2015 13:00:47 -0500 Subject: [PATCH] Introduce "either" helper for Handlebars themes. --- src/eng/handlebars-helpers.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/eng/handlebars-helpers.js b/src/eng/handlebars-helpers.js index 81ed94c..c765ca1 100644 --- a/src/eng/handlebars-helpers.js +++ b/src/eng/handlebars-helpers.js @@ -49,6 +49,12 @@ Template helper definitions for Handlebars. return txt && txt.trim() ? _.initial( txt.split(' ') ).join(' ') : ''; }); + // Set up a Markdown-to-WordProcessingML helper so we can do: + // {{either A B}} + HANDLEBARS.registerHelper("either", function( lhs, rhs, options ) { + if (lhs || rhs) return options.fn(this); + }); + // Set up a generic conditional helper so we can do: // {{compare val otherVal operator="<"}} // http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates/