1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 09:30:28 +00:00

Fix invocation of JS macros

This commit is contained in:
jeremy@jermolene.com 2022-05-21 16:31:34 +01:00
parent e50101322f
commit ec1ec8ccd8
3 changed files with 21 additions and 3 deletions

View File

@ -200,8 +200,8 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
$tw.utils.each(srcVariable.params,function(param) {
$tw.utils.addAttributeToParseTreeNode(parser.tree[0],param.name,param["default"])
});
} else if(srcVariable.isMacroDefinition) {
// For macros, wrap the parse tree in a vars widget assigning the parameters to variables named "__paramname__"
} else {
// For macros and ordinary variables, wrap the parse tree in a vars widget assigning the parameters to variables named "__paramname__"
parser = {
tree: [
{

View File

@ -148,7 +148,8 @@ Widget.prototype.getVariableInfo = function(name,options) {
}
// If the variable doesn't exist in the parent widget then look for a macro module
return {
text: this.evaluateMacroModule(name,actualParams,options.defaultValue)
text: this.evaluateMacroModule(name,actualParams,options.defaultValue),
srcVariable: {}
};
};

View File

@ -0,0 +1,17 @@
title: Transclude/Macro/JavaScript
description: Transcluding a javascript macro
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
title: Output
\whitespace trim
<<makedatauri text:"Wildebeest" type:"text/plain">>
<$macrocall $name="makedatauri" text="Wildebeest" type="text/plain"/>
+
title: ExpectedResult
<p><a class="tc-tiddlylink-external" href="data:text/plain,Wildebeest" rel="noopener noreferrer" target="_blank">data:text/plain,Wildebeest</a></p><p><a class="tc-tiddlylink-external" href="data:text/plain,Wildebeest" rel="noopener noreferrer" target="_blank">data:text/plain,Wildebeest</a></p>