diff --git a/core/modules/widgets/parameters.js b/core/modules/widgets/parameters.js index 239fc1583..f3bb4ebbe 100644 --- a/core/modules/widgets/parameters.js +++ b/core/modules/widgets/parameters.js @@ -49,16 +49,13 @@ ParametersWidget.prototype.execute = function() { } // Process each parameter if(transclusionWidget) { - var paramNames = [], paramValues = []; $tw.utils.each($tw.utils.getOrderedAttributesFromParseTreeNode(self.parseTreeNode),function(attr,index) { var name = attr.name, value = transclusionWidget.getTransclusionParameter(name,index,self.getAttribute(name)); self.setVariable(name,value); - paramNames.push(name); - paramValues.push(value); - }); - self.setVariable("paramNames",$tw.utils.stringifyList(paramNames)); - self.setVariable("paramValues",$tw.utils.stringifyList(paramValues)); + }); + this.setVariable("paramNames",$tw.utils.stringifyList(transclusionWidget.getTransclusionParameterNames())); + this.setVariable("paramValues",$tw.utils.stringifyList(transclusionWidget.getTransclusionParameterValues())); } // Construct the child widgets this.makeChildWidgets(); diff --git a/core/modules/widgets/transclude.js b/core/modules/widgets/transclude.js index 9acf3a469..734e17f25 100755 --- a/core/modules/widgets/transclude.js +++ b/core/modules/widgets/transclude.js @@ -177,16 +177,12 @@ TranscludeWidget.prototype.getTransclusionTarget = function() { tree: [ { type: "parameters", - children: parser.tree, - attributes: {}, - orderedAttributes: [] + children: parser.tree } ] } - $tw.utils.each(variableInfo.variableParams,function(param,index) { - var attr = {name: param.name, type: "string", value: param["default"]}; - parser.tree[0].attributes[param.name] = attr; - parser.tree[0].orderedAttributes.push(attr); + $tw.utils.each(variableInfo.variableParams,function(param) { + $tw.utils.addAttributeToParseTreeNode(parser.tree[0],param.name,param["default"]) }); } } @@ -232,16 +228,23 @@ TranscludeWidget.prototype.getTransclusionParameter = function(name,index,defaul return defaultValue; }; +/* +Get an array of the names of all the provided transclusion parameters +*/ +TranscludeWidget.prototype.getTransclusionParameterNames = function() { + return Object.keys(this.stringParametersByName); +}; /* -Fetch the value of a parameter identified by its position +Get an array of the values of all the provided transclusion parameters */ -TranscludeWidget.prototype.getTransclusionParameterByPosition = function(index,defaultValue) { - if(index in this.stringParametersByPosition) { - return this.stringParametersByPosition[index]; - } else { - return defaultValue; - } +TranscludeWidget.prototype.getTransclusionParameterValues = function() { + var self = this, + values = []; + $tw.utils.each(Object.keys(this.stringParametersByName),function(name) { + values.push(self.stringParametersByName[name]); + }); + return values; }; /* diff --git a/editions/test/tiddlers/tests/data/transclude/CustomWidget-OverrideUbertransclude.tid b/editions/test/tiddlers/tests/data/transclude/CustomWidget-OverrideTransclude.tid similarity index 100% rename from editions/test/tiddlers/tests/data/transclude/CustomWidget-OverrideUbertransclude.tid rename to editions/test/tiddlers/tests/data/transclude/CustomWidget-OverrideTransclude.tid diff --git a/editions/test/tiddlers/tests/data/transclude/Parameterised-Name-Values.tid b/editions/test/tiddlers/tests/data/transclude/Parameterised-Name-Values.tid index 19aeeb3e8..07cf5c316 100644 --- a/editions/test/tiddlers/tests/data/transclude/Parameterised-Name-Values.tid +++ b/editions/test/tiddlers/tests/data/transclude/Parameterised-Name-Values.tid @@ -28,4 +28,4 @@ title: TiddlerTwo _ title: ExpectedResult -
{zero:Jaguar}{one:Lizard}{two:Mole}
{zero:Ferret}{one:Lizard}{two:Mole}
{zero:Butterfly}{one:Moth}{two:Mole}
{zero:Beetle}{one:Scorpion}{two:Snake}
({zero:Beetle}{one:Scorpion}{two:Snake})
\ No newline at end of file +{0:Ferret}
{0:Butterfly}{1:Moth}
{0:Beetle}{1:Scorpion}{2:Snake}
({zero:Beetle}{one:Scorpion}{two:Snake})
\ No newline at end of file