Corrected version of 'link' helper that accepts arrays of links.
authorMike Taylor <mike@indexdata.com>
Wed, 27 Nov 2013 16:36:36 +0000 (16:36 +0000)
committerMike Taylor <mike@indexdata.com>
Wed, 27 Nov 2013 16:36:36 +0000 (16:36 +0000)
tools/htdocs/mkws.js

index 1a58f58..48ec152 100644 (file)
@@ -101,16 +101,19 @@ mkws.debug_function = function (string) {
 var debug = mkws.debug_function; // local alias
 
 
-Handlebars.registerHelper('link', function(text, url) {
-  text = Handlebars.Utils.escapeExpression(text);
-  url  = Handlebars.Utils.escapeExpression(url);
-
-  var result = '<a href="' + url + '">' + text + '</a>';
+Handlebars.registerHelper('link', function(a) {
+    var result = "";
+    for (var i in a) {
+       if (i > 0) result += "<br/>";
+       var text = Handlebars.Utils.escapeExpression(a[i]);
+       result += '<a href="' + text + '">' + text + '</a>';
+    }
 
-  return new Handlebars.SafeString(result);
+    return new Handlebars.SafeString(result);
 });
 
 
+
 {
     /* default mkws config */
     var config_default = {