diff options
author | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2017-02-27 12:24:32 +0100 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@fri.uni-lj.si> | 2017-02-27 12:24:32 +0100 |
commit | 3a79392cf8fd781f0a746ae4123d9208cb04735b (patch) | |
tree | 232c3964ca1a83f1a3d665175a416188aded9b03 | |
parent | 10b30455e9f70ab799f93316ec4f4edd8a88cac6 (diff) |
Allow passing lists as template arguments
-rw-r--r-- | js/codeq/template.js | 18 |
1 files 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 <http://www.gnu.org/licenses/>. */ 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 <http://www.gnu.org/licenses/>. */ } 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 += '<li>' + codeq.escapeHtml(value[i]) + '</li>'; + } + } + else { + output += codeq.escapeHtml(value); + } break; case '@': // a directive handler = directiveHandlers[match[2]]; |