From 3a79392cf8fd781f0a746ae4123d9208cb04735b Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 27 Feb 2017 12:24:32 +0100 Subject: Allow passing lists as template arguments --- js/codeq/template.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/js/codeq/template.js b/js/codeq/template.js index ec8b080..86d8116 100644 --- a/js/codeq/template.js +++ b/js/codeq/template.js @@ -117,13 +117,6 @@ along with this program. If not, see . */ key, subpart, start, end, match, handler, output = ''; - // escape arguments - args = args || {}; - for (key in args) { - if (!args.hasOwnProperty(key)) continue; - args[key] = codeq.escapeHtml(args[key]); - } - if (!templatePath) templatePath = []; templateName = templatePath.join('/'); @@ -151,7 +144,16 @@ along with this program. If not, see . */ } switch (match[1]) { case '=': // a value reference - output += String(args[match[2]]); + var value = args[match[2]]; + if (Array.isArray(value)) { + var i; + for (i = 0; i < value.length; i++) { + output += '
  • ' + codeq.escapeHtml(value[i]) + '
  • '; + } + } + else { + output += codeq.escapeHtml(value); + } break; case '@': // a directive handler = directiveHandlers[match[2]]; -- cgit v1.2.1