From b7812b5de4b67a37c78150c15bfaea2e00ac5e02 Mon Sep 17 00:00:00 2001 From: Jeff Williams Date: Fri, 9 Jan 2015 12:54:53 -0800 Subject: [PATCH] support properties on objects in arrays (#870) --- templates/default/tmpl/params.tmpl | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/templates/default/tmpl/params.tmpl b/templates/default/tmpl/params.tmpl index 66ab0459..336fb5ad 100644 --- a/templates/default/tmpl/params.tmpl +++ b/templates/default/tmpl/params.tmpl @@ -4,12 +4,21 @@ /* sort subparams under their parent params (like opts.classname) */ var parentParam = null; params.forEach(function(param, i) { - if (!param) { return; } - if ( parentParam && param.name && param.name.indexOf(parentParam.name + '.') === 0 ) { - param.name = param.name.substr(parentParam.name.length+1); - parentParam.subparams = parentParam.subparams || []; - parentParam.subparams.push(param); - params[i] = null; + var paramRegExp; + + if (!param) { + return; + } + + if (parentParam && parentParam.name && param.name) { + paramRegExp = new RegExp('^(?:' + parentParam.name + '(?:\\[\\])*)\\.(.+)$'); + + if ( paramRegExp.test(param.name) ) { + param.name = RegExp.$1; + parentParam.subparams = parentParam.subparams || []; + parentParam.subparams.push(param); + params[i] = null; + } } else { parentParam = param; @@ -109,4 +118,4 @@ - \ No newline at end of file +