How to pass the parameter from macrocall to js macro?

I get js script macro tiddler.

/*\
title: JsTiddler
type: application/javascript
module-type: macro
\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

exports.name = "jstiddler";

exports.params = [
    {name: "AppleDefault"}
];

/*
Run the macro
*/
exports.run = function(name) {
    return "Hello " + name;
};

})();

And another tiddler to run it

<$importvariables filter="[[JsTiddler]]">
<$macrocall $name="jstiddler" name="Banana" />
</$importvariables>

But I only get Hello no ‘banana’ why is this?

Another question

I checked the core module js macro, I know that the now.js has a parameter.
So I search it in the advanced search and get this:

I can’t step forward until now, I can’t get what I want in the core tiddler. So what should I do next ?

Click on “Shadows”.

Your javascript name and default setup should be like this:

exports.name = "jstiddler";

exports.params = [
    {name: "name", default: "AppleDefault"}
];
1 Like

shadows give me this I still don’t know which tiddler call the now.js file.

1 Like

## $:/core/modules/macros/now.js creates a macro that we call with <<now>> as documented in now Macro

Ori, I think you need to explain more clearly what you want to do? what are you trying to learn or achieve?

<<now YYYY-0MM0DD>>

1 Like

Sorry for the unclearly my English not that good, I will learn it harder.

My point is I want to solve the call js macro by macrocall question(Yes just the question in this post) by myself and I stuck at how to find the tiddler which call the now.js

Here is my try

  1. I found this link: https://tiddlywiki.com/dev/static/JavaScript%20Macros.html, which told me to check the build-in js as example. And provide this link: TiddlyWiki5/core/modules/macros at master ¡ Jermolene/TiddlyWiki5 ¡ GitHub.
  2. In the build-in js macros. I found now.js has its parameter, so I just find which tiddler has called the now.js macro I will know how to set the parameter.
  3. So I go to advance search and search for “now.js”. The result of the advanced search can’t help me find the caller.

image

image

Core tiddler contains so many things I can’t find exactly what I want.

Till now I can’t step forward. So I need to know how to find which tiddler call now.js.

Hope I make it clearly this time.

Hi @Ori you can where the core calls the “now” macro by searching the shadows for <now. That will find invocations within filters (eg [<now>]) and within wikitext (eg <<now>>). It won’t find calls via explicit <$macrocall widgets.

The definition of your macro parameters should look like this:

exports.params = [
    {name: "name"}
];

And then the invocation <$macrocall $name="jstiddler" name="Banana" /> should work as expected.

1 Like

Thank you I know how to search for the caller of macro. I should think of it by myself, Thank you again.