Provide new Handlebars helper mkws-best-url, which returns the first
item in a list that matches a regular-expression suggesting that it's
a URL (basically anything that starts with http://, https:// or //).
Also provide mkws-other-urls (not yet tested), which returns all the
other URLs in the list except the first.
});
+var _urlRegexp = /^(https?:)?\/\//;
+Handlebars.registerHelper('mkws-best-url', function(items) {
+ for (var i in items) {
+ var item = items[i]
+ if (item.match(_urlRegexp)) {
+ mkws.warn("'" + item + "' *is* a URL");
+ return item;
+ }
+ mkws.warn("'" + item + "' is not a URL");
+ }
+ return "";
+});
+Handlebars.registerHelper('mkws-other-urls', function(items) {
+ var res = [];
+ for (var i in items) {
+ var item = items[i]
+ if (item.match(_urlRegexp)) {
+ res.push(item);
+ }
+ }
+ return res;
+});
+
+
+
Handlebars.registerHelper('mkws-commaList', function(items, options) {
var out = "";