1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-01 09:43:16 +00:00

Ubertransclusion positional parameters should be based on name, not position

This commit is contained in:
jeremy@jermolene.com 2022-04-29 16:28:03 +01:00
parent 9713da5071
commit 89b7a3bd28
2 changed files with 8 additions and 8 deletions

View File

@ -51,7 +51,7 @@ ParametersWidget.prototype.execute = function() {
if(transclusionWidget) {
$tw.utils.each($tw.utils.getOrderedAttributesFromParseTreeNode(self.parseTreeNode),function(attr,index) {
var name = attr.name;
self.setVariable(name,transclusionWidget.getTransclusionParameter(name,transclusionWidget.getTransclusionParameterByPosition(index,self.getAttribute(name))));
self.setVariable(name,transclusionWidget.getTransclusionParameter(name,index,self.getAttribute(name)));
});
}
// Construct the child widgets

View File

@ -49,10 +49,7 @@ UberTranscludeWidget.prototype.execute = function() {
this.recursionMarker = this.getAttribute("$recursionMarker","yes");
// Collect the string parameters
this.stringParametersByName = Object.create(null);
this.stringParametersByPosition = [];
var stringParameterIndex = 0;
$tw.utils.each($tw.utils.getOrderedAttributesFromParseTreeNode(this.parseTreeNode),function(attr) {
var name = attr.name, value = self.getAttribute(name);
$tw.utils.each(this.attributes,function(value,name) {
if(name.charAt(0) === "$") {
if(name.charAt(1) === "$") {
// Attributes starting $$ represent parameters starting with a single $
@ -63,7 +60,6 @@ UberTranscludeWidget.prototype.execute = function() {
}
}
self.stringParametersByName[name] = value;
self.stringParametersByPosition[stringParameterIndex++] = value;
});
// Collect the value widgets in our child parse tree
this.slotValueParseTrees = Object.create(null);
@ -137,12 +133,16 @@ UberTranscludeWidget.prototype.execute = function() {
/*
Fetch the value of a parameter
*/
UberTranscludeWidget.prototype.getTransclusionParameter = function(name,defaultValue) {
UberTranscludeWidget.prototype.getTransclusionParameter = function(name,index,defaultValue) {
if(name in this.stringParametersByName) {
return this.stringParametersByName[name];
} else {
return defaultValue;
var name = "" + index;
if(name in this.stringParametersByName) {
return this.stringParametersByName[name];
}
}
return defaultValue;
};