1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-02 22:39:56 +00:00

Simplify metaparameters implementation

This commit is contained in:
jeremy@jermolene.com 2022-06-03 11:21:32 +01:00
parent b57a6da548
commit 542df63ccf
2 changed files with 19 additions and 19 deletions

View File

@ -68,15 +68,12 @@ ParametersWidget.prototype.execute = function() {
self.setVariable(name,value);
});
// Assign any metaparameters
var assignMetaParameter = function(name) {
$tw.utils.each(pointer.getTransclusionMetaParameters(),function(getValue,name) {
var variableName = self.getAttribute("$" + name);
if(variableName !== undefined) {
self.setVariable(variableName,pointer.getTransclusionMetaParameter(name));
self.setVariable(variableName,getValue(name));
}
};
assignMetaParameter("parseAsInline");
assignMetaParameter("parseTreeNodes");
assignMetaParameter("params");
});
}
// Construct the child widgets
this.makeChildWidgets();

View File

@ -306,19 +306,22 @@ TranscludeWidget.prototype.getTransclusionParameter = function(name,index,defaul
/*
Get one of the special parameters to be provided by the parameters widget
*/
TranscludeWidget.prototype.getTransclusionMetaParameter = function(name) {
switch(name) {
case "parseAsInline":
return this.parseAsInline ? "yes" : "no";
case "parseTreeNodes":
return JSON.stringify(this.parseTreeNode);
case "slotFillParseTrees":
return JSON.stringify(this.slotFillParseTrees);
case "params":
return JSON.stringify(this.stringParametersByName);
default:
return "";
}
TranscludeWidget.prototype.getTransclusionMetaParameters = function() {
var self = this;
return {
"parseAsInline": function() {
return self.parseAsInline ? "yes" : "no";
},
"parseTreeNodes": function() {
return JSON.stringify(self.parseTreeNode);
},
"slotFillParseTrees": function() {
return JSON.stringify(self.slotFillParseTrees);
},
"params": function() {
JSON.stringify(self.stringParametersByName);
}
};
};
/*