mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-28 02:50:27 +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}
|
||||
},
|
||||
children: [],
|
||||
params: params
|
||||
params: params,
|
||||
isMacroDefinition: true
|
||||
}];
|
||||
};
|
||||
|
||||
|
@ -63,7 +63,8 @@ ImportVariablesWidget.prototype.execute = function(tiddlerList) {
|
||||
addWidgetNode({
|
||||
type: "set",
|
||||
attributes: parseTreeNode.attributes,
|
||||
params: parseTreeNode.params
|
||||
params: parseTreeNode.params,
|
||||
isMacroDefinition: parseTreeNode.isMacroDefinition
|
||||
});
|
||||
parseTreeNode = parseTreeNode.children[0];
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ SetWidget.prototype.execute = function() {
|
||||
this.setValue = this.getAttribute("value");
|
||||
this.setEmptyValue = this.getAttribute("emptyValue");
|
||||
// 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
|
||||
this.makeChildWidgets();
|
||||
};
|
||||
|
@ -71,9 +71,10 @@ Set the value of a context variable
|
||||
name: name of the variable
|
||||
value: value of the variable
|
||||
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) {
|
||||
this.variables[name] = {value: value, params: params};
|
||||
Widget.prototype.setVariable = function(name,value,params,isMacroDefinition) {
|
||||
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) {
|
||||
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 {
|
||||
text: value,
|
||||
params: params
|
||||
|
Loading…
Reference in New Issue
Block a user