mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-02 22:39:56 +00:00
Simplify metaparameters implementation
This commit is contained in:
parent
b57a6da548
commit
542df63ccf
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user