Hi there, 
I wanted to make a string replacement and found no other possibility as to 
do it with a javascript macro.
So I found at http://tw5magick.tiddlyspot.com/ the following source code:



/*\
title: $:/macros/skeeve/mysamplemacro.js
type: application/javascript
module-type: macro

<<mysamplemacro character address>>

Example:
<<mysamplemacro>>
<<mysamplemacro "Donald Duck">>
<<mysamplemacro "Mickey Mouse" "Mouse House">>

\*/
(function(){

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

/*
Information about this macro
This is the mysamplemacro of Tiddly Wiki 5 written in JavaScript 
*/

exports.name = "mysamplemacro";

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

/*
Run the macro
*/
exports.run = function(character, address) {
if( !character) character = "Bugs Bunny";
if( !address) address = "Rabbit Hole Hill";
var output ="Hi, I'm " + character + " and I live in " + address;
return output;
};

})();



I just copied to my wiki and named it $:/macros/skeeve/mysamplemacro.js 
like it was before.
Then I tried to call it within a tiddler named jsTest:


<<mysamplemacro>>
<<mysamplemacro "Donald Duck">>
<<mysamplemacro "Mickey Mouse" "Mouse House">>



But this did not work, there was no output.

So what went wrong???


I have read this: http://tiddlywiki.com/dev/index.html#JavaScript%20Macros

I wondered where to find and to set the module type.

Is this just done by putting one line in the macro source code like 
"module-type: macro"?

As there is the speaking of a module-type "field" I expected to find it at the 
bottom of a tiddler in "Edit"-Mode between the System fields like 
current-tiddler, library or plugin type.

Also it is not clear to me if I have to tag the js-macro with $:/tags/Macro as 
the normal wikitext macros.

Also the naming convention is not clear to me. I want this macro globally 
accessible, but not mixed up in between the system macros. 


I would be happy about suggestions to why my js macro is not working as I found 
the documentation about that a bit limited.

Thank you very much!

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/80fa8613-993d-4ed8-af62-c75619980e32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to