Okay, I'm pretty sure I've gotten a $macrocall with named parameters
version working.
Here is the demo tiddler:
\define buttonmacro3(countUp param1 param2)
<$button style="background-color:White; width:100%; height:100%" >"""
$param1$ $param2$ $countUp$
"""</$button>
\end
\define interimmacro2(countUp caption1 caption2)
<$macrocall $name=repeatmacroxv5 targetMacro=buttonmacro3 x=$countUp$
parameterPassing="param1=$caption1$ param2=$caption2$"/>
\end
<$macrocall $name=repeatmacroxv5 targetMacro=buttonmacro3 x=3
parameterPassing="param1=Buttons param2=Words"/>
<<interimmacro2 4 Dog Cat>>
<<interimmacro2 2 Moose Squirrel>>
And here is the javascript:
/*\
title: $:/_my/macros/repeatmacroxv5.js
type: application/javascript
module-type: macro
Macro to return a macro multiple times
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Information about this macro
*/
exports.name = "repeatmacroxv5";
exports.params = [
{name: "targetMacro"},
{name: "x"},
{name: "parameterPassing"}
];
/*
Run the macro
*/
exports.run = function(targetMacro,x,parameterPassing) {
var i;
var result;
for (i = 0; i < x; i++) {
if (i == 0) {
result = "<$macrocall $name=" + targetMacro + " countUp=" + String(i + 1) + "
" + parameterPassing + " />";
} else {
result += "<$macrocall $name=" + targetMacro + " countUp=" + String(i + 1)
+ " " + parameterPassing + " />";
}
}
return result;
};
})();
It's not the most elegant design, but it is still a working way to do this.
I'm still interested if somebody knows a better way though.
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/4286190b-b8c5-416d-abbf-11581ba96e98%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.