5th July, 2020
Start by copying or forking the HelloWorld macro from here. Import this your TW by following the following steps:
- Create a new tiddly and paste the code into the edit-text box
- Put the title as
- Enter the type under the textbox as
- Add a new field with field-name as
module-type and field value as
- Save the tiddly (make sure the wiki is saved too) and refresh your browser tab.
To run the macro, you will need to open a new tiddly with title
Hello World Test (or anything else) and paste the following code into the edit-text box:
<<helloworld>>. When you save it, you should see the Tiddly show the Hello World! message.
So this HelloWorld macro has an optional parameter you can pass. If you change the call to
<<helloworld Adithya>>, you will get a Hello Adithya! message. Now, you can extend this to many more things. I made a small timediff macro which you can find here.
Some tips and tricks
- Always make a copy of your TW to try out these things. If things break, you might lose data.
- I tested out my function on https://jsbin.com before putting it into the TW
- Look at the core JS macros available here: https://github.com/Jermolene/TiddlyWiki5/tree/master/core/modules/macros for reference.
- When you make save your macro, it becomes a "System Tiddler" so you can find it by clicking on the more button in the sidebar and looking under the 'System' tab. You cant find it by searching or in the 'recents' tab.
- For easy acces to the macro, make a link by putting
[[$:/adithyab/macros/helloworld.js]] in one of your starting tiddlies.
- The try...catch block makes sure if something breaks in your macro, your TW is still operable. If your get an error, you can get the stacktrace by entering the debugger mode.
- Ask the super helpful folk in the TW google group at https://groups.google.com/forum/#!forum/tiddlywiki if you need help with anything.