From 92128da3817ee8cb4bdc3a369dd4e8186259faac Mon Sep 17 00:00:00 2001 From: hacksalot Date: Fri, 18 Dec 2015 14:51:51 -0500 Subject: [PATCH] Install URL-trimming helper. --- 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 c765ca1..6e255b3 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 URL-trimming helper to drop the protocol so we can do: + // {{trimURL url}} + HANDLEBARS.registerHelper("trimURL", function( url ) { + return url && url.trim() ? url.trim().replace(/^https?:\/\//i, '') : ''; + }); + // Set up a Markdown-to-WordProcessingML helper so we can do: // {{either A B}} HANDLEBARS.registerHelper("either", function( lhs, rhs, options ) {