Last active
July 5, 2020 10:54
-
-
Save adithya-badidey/7f96e27ebe25194c6b6ec2fbd9710e15 to your computer and use it in GitHub Desktop.
A helloworld macro for TiddlyWiki!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*\ | |
title: $:/adithyab/macros/helloworld.js | |
type: application/javascript | |
module-type: macro | |
A helloworld JS macro for Tiddlywiki! | |
Visit https://adithyab.in/2020/how-to-make-a-basic-javascript-macro-in-tiddlywiki/ | |
\*/ | |
(function() { | |
/*jslint node: true, browser: true */ | |
/*global $tw: false */ | |
"use strict"; | |
exports.name = "helloworld"; | |
exports.params = [{ | |
name: "var1", | |
default: "World" | |
}, | |
/* {name: "var2"} - The default parameter is optional*/ | |
]; | |
/* | |
Run the macro. Make sure it accepts the parameters you have defined above. | |
*/ | |
exports.run = function(var1) { | |
try { | |
return "Hello " + var1 + "!!" | |
} catch (err) { | |
console.error(err.stack) | |
return "(ERROR: " + err.message + ") "; | |
} | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment