Fixed substitute attributes to allow more variables (#9059)

This commit is contained in:
Cameron Fischer 2025-06-03 12:30:40 -04:00 committed by GitHub
parent 48b45f0e35
commit f1b33c02f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View file

@ -1173,7 +1173,7 @@ exports.getSubstitutedText = function(text,widget,options) {
output = $tw.utils.replaceString(output,new RegExp("\\$" + $tw.utils.escapeRegExp(substitute.name) + "\\$","mg"),substitute.value);
});
// Substitute any variable references with their values
return output.replace(/\$\(([^\)\$]+)\)\$/g, function(match,varname) {
return output.replace(/\$\((.+?)\)\$/g, function(match,varname) {
return widget.getVariable(varname,{defaultValue: ""})
});
};

View file

@ -7,9 +7,9 @@ title: Output
\whitespace trim
<$set name="var with spaces" value="spaces">
<$let project="TiddlyWiki" disabled="true" var-with-dashes="dashes">
<$let project="TiddlyWiki" disabled="true" $tiddler="Getting Started" var-with-dashes="dashes">
<div class=`$(project)$
${ [[Hello]addsuffix[There]] }$` attrib=`myvalue` otherattrib=`$(1)$` blankattrib=`` quoted="here" disabled=```$(disabled)$``` dashes=`$(var-with-dashes)$` spaces=`$(var with spaces)$`>
${ [[Hello]addsuffix[There]] }$` attrib=`myvalue` otherattrib=`$(1)$` blankattrib=`` quoted="here" disabled=```$(disabled)$``` dollar=`p-$($tiddler)$-s` dashes=`$(var-with-dashes)$` spaces=`$(var with spaces)$`>
</div>
</$let>
</$set>
@ -18,4 +18,4 @@ ${ [[Hello]addsuffix[There]] }$` attrib=`myvalue` otherattrib=`$(1)$` blankattri
title: ExpectedResult
<p><div attrib="myvalue" blankattrib="" class="TiddlyWiki
HelloThere" dashes="dashes" disabled="true" otherattrib="" quoted="here" spaces="spaces"></div></p>
HelloThere" dashes="dashes" disabled="true" dollar="p-Getting Started-s" otherattrib="" quoted="here" spaces="spaces"></div></p>