mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-06-25 23:03:15 +00:00
Restrict variable substitutions to macros defined with the define pragma
Fixes #3333
This commit is contained in:
parent
aba9c94f5a
commit
35cbb127a3
|
@ -84,7 +84,8 @@ exports.parse = function() {
|
||||||
value: {type: "string", value: text}
|
value: {type: "string", value: text}
|
||||||
},
|
},
|
||||||
children: [],
|
children: [],
|
||||||
params: params
|
params: params,
|
||||||
|
isMacroDefinition: true
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,8 @@ ImportVariablesWidget.prototype.execute = function(tiddlerList) {
|
||||||
addWidgetNode({
|
addWidgetNode({
|
||||||
type: "set",
|
type: "set",
|
||||||
attributes: parseTreeNode.attributes,
|
attributes: parseTreeNode.attributes,
|
||||||
params: parseTreeNode.params
|
params: parseTreeNode.params,
|
||||||
|
isMacroDefinition: parseTreeNode.isMacroDefinition
|
||||||
});
|
});
|
||||||
parseTreeNode = parseTreeNode.children[0];
|
parseTreeNode = parseTreeNode.children[0];
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ SetWidget.prototype.execute = function() {
|
||||||
this.setValue = this.getAttribute("value");
|
this.setValue = this.getAttribute("value");
|
||||||
this.setEmptyValue = this.getAttribute("emptyValue");
|
this.setEmptyValue = this.getAttribute("emptyValue");
|
||||||
// Set context variable
|
// Set context variable
|
||||||
this.setVariable(this.setName,this.getValue(),this.parseTreeNode.params);
|
this.setVariable(this.setName,this.getValue(),this.parseTreeNode.params,!!this.parseTreeNode.isMacroDefinition);
|
||||||
// Construct the child widgets
|
// Construct the child widgets
|
||||||
this.makeChildWidgets();
|
this.makeChildWidgets();
|
||||||
};
|
};
|
||||||
|
|
|
@ -71,9 +71,10 @@ Set the value of a context variable
|
||||||
name: name of the variable
|
name: name of the variable
|
||||||
value: value of the variable
|
value: value of the variable
|
||||||
params: array of {name:, default:} for each parameter
|
params: array of {name:, default:} for each parameter
|
||||||
|
isMacroDefinition: true if the variable is set via a \define macro pragma (and hence should have variable substitution performed)
|
||||||
*/
|
*/
|
||||||
Widget.prototype.setVariable = function(name,value,params) {
|
Widget.prototype.setVariable = function(name,value,params,isMacroDefinition) {
|
||||||
this.variables[name] = {value: value, params: params};
|
this.variables[name] = {value: value, params: params, isMacroDefinition: !!isMacroDefinition};
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -102,7 +103,11 @@ Widget.prototype.getVariableInfo = function(name,options) {
|
||||||
$tw.utils.each(params,function(param) {
|
$tw.utils.each(params,function(param) {
|
||||||
value = $tw.utils.replaceString(value,new RegExp("\\$" + $tw.utils.escapeRegExp(param.name) + "\\$","mg"),param.value);
|
value = $tw.utils.replaceString(value,new RegExp("\\$" + $tw.utils.escapeRegExp(param.name) + "\\$","mg"),param.value);
|
||||||
});
|
});
|
||||||
value = this.substituteVariableReferences(value);
|
// Only substitute variable references if this variable was defined with the \define pragma
|
||||||
|
if(value.slice(0,4) ==="{{$(") {debugger;}
|
||||||
|
if(variable.isMacroDefinition) {
|
||||||
|
value = this.substituteVariableReferences(value);
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
text: value,
|
text: value,
|
||||||
params: params
|
params: params
|
||||||
|
|
Loading…
Reference in New Issue
Block a user