Skip to content

Instantly share code, notes, and snippets.

@adithya-badidey
Last active July 5, 2020 10:54
Show Gist options
  • Save adithya-badidey/7f96e27ebe25194c6b6ec2fbd9710e15 to your computer and use it in GitHub Desktop.
Save adithya-badidey/7f96e27ebe25194c6b6ec2fbd9710e15 to your computer and use it in GitHub Desktop.
A helloworld macro for TiddlyWiki!
/*\
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