1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-11-18 00:05:15 +00:00

Extend transclude widget to work with old-style macros and use it for the macrocall shortcut syntax

This commit is contained in:
jeremy@jermolene.com
2022-05-08 15:59:20 +01:00
parent 9be05f6f38
commit e9630328f1
7 changed files with 152 additions and 46 deletions

View File

@@ -122,14 +122,14 @@ Widget.prototype.getVariableInfo = function(name,options) {
if(parentWidget && name in parentWidget.variables) {
var variable = parentWidget.variables[name],
originalValue = variable.value,
value = originalValue,
params = this.resolveVariableParameters(variable.params,actualParams);
// Substitute any parameters specified in the definition
$tw.utils.each(params,function(param) {
value = $tw.utils.replaceString(value,new RegExp("\\$" + $tw.utils.escapeRegExp(param.name) + "\\$","mg"),param.value);
});
// Only substitute variable references if this variable was defined with the \define pragma
value = originalValue;
// Only substitute parameter and variable references if this variable was defined with the \define pragma
if(variable.isMacroDefinition) {
var params = this.resolveVariableParameters(variable.params,actualParams);
// Substitute any parameters specified in the definition
$tw.utils.each(params,function(param) {
value = $tw.utils.replaceString(value,new RegExp("\\$" + $tw.utils.escapeRegExp(param.name) + "\\$","mg"),param.value);
});
value = this.substituteVariableReferences(value,options);
}
return {