JavaScript macros driving me crazy

113 views
Skip to first unread message

Tristan Kohl

unread,
Mar 23, 2016, 3:56:49 PM3/23/16
to TiddlyWiki
Hey guys,

I finally dare digging into the whole TiddlyWiki magic underneath the fancy UI.
At first I tried to get a JavaScript Macro running but failed miserably.

This is my code:
/*\
title: $:/mirodin/macro/tester.js
type: application/javascript
module-type: macro

\*/

(function(){

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

/*
An example js macro.
*/


exports
.name = "tester";

exports
.params = [];

/*
Run the macro
*/

exports
.run = function() {
   
return "TESTER";
};

})();

I also set the type field to application/javascript and the module_type to macro but when I called it within an new tiddler (after page refresh) via <<tester>> there was no output.
I figure I miss anything super obvious but I do not have a clue what might that be. Any help/hint/tip would be very much appreciated.

Thanks
Tristan

Eric Shulman

unread,
Mar 23, 2016, 4:21:29 PM3/23/16
to TiddlyWiki
On Wednesday, March 23, 2016 at 12:56:49 PM UTC-7, Tristan Kohl wrote:
I also set the type field to application/javascript and the module_type to macro but when I called it within an new tiddler (after page refresh) via <<tester>> there was no output.

Not sure if it's just a typo in your message, but the field name is "module-type "... not "module_type" (i.e., use dash... not underscore).  If the module-type field name wasn't correctly defined, that would prevent the macro from being loaded at startup. Thus, when the <<tester>> macro syntax is processed, there is no known macro t o be invoked, so no output is produced.

hope this helps,

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
InsideTiddlyWiki: The Missing Manuals

Tristan Kohl

unread,
Mar 24, 2016, 9:22:05 AM3/24/16
to TiddlyWiki
Ah, I knew it was some stupid little thing :/

Thank you very much, I suspect that I would never have found this on my own.

Cheers
Tristan
Reply all
Reply to author
Forward
0 new messages