This is a stripped-down version of a single section of Grok TiddlyWiki, optimized for fast loading and readability by search engines. Some features are missing.
For the full Grok TiddlyWiki experience, please visit the wiki version of this page.
So far, macros have been very useful for reducing repetition and implementing Text Substitution within tiddlers, but we haven't seen any way to make them available in more than one tiddler, which has somewhat limited their usefulness.
Now that we've looked at system tiddlers, however, there's an easy way to make a macro available in all tiddlers, which is a useful shortcut if you find yourself needing the same formatting or snippets of text over and over again and a template isn't convenient. Such macros are commonly referred to as global macros.
The trick is a special tag, $:/tags/Macro (don't forget the capital
M – as always, tiddler titles are case-sensitive). When TiddlyWiki displays a tiddler, it looks through all tiddlers with this tag, gathers the macros they contain, and effectively prepends them to the tiddler being displayed. (It's a little more complicated behind the scenes, but it's safe to think of it this way.) Therefore, they're available for use in every tiddler.
If you want to make a macro available in more than one tiddler, but not in all of them, another option is to use the
\import pragma. This takes a filter as an argument, so to import macros from all tiddlers tagged
MyAwesomePrivateMacros, you would put the following at the top of a tiddler:
Internally, TiddlyWiki actually imports your global macros using this
\import pragma on the page template (
$:/core/ui/PageTemplate), which is responsible for transcluding all other parts of the wiki that appear on screen at any given time.
ticketLink macros we created in the The Finer Points of Macros section and turn them into global macros, creating one or more system tiddlers under a user folder to house them (e.g., you could put both in
$:/yournamehere/LinkMacros, or put one in
Remove the original macro definitions from the individual tiddlers and try calling the macros from a few different tiddlers to make sure it works.
Search for all tiddlers that currently contain global macros. Remember that most of these will be stored in shadow tiddlers, so you'll need to say you want to filter on shadow tiddlers to get any results.
Spend a few minutes browsing through some of the tiddlers that come up and looking at some of the system macro definitions. You'll recognize some of the macros from previous chapters, and you should be able to understand a good portion of what's going on. There's no magic – the built-in macros are simply wrapping up some complicated HTML and widgets for us to use in a convenient way, just like we would do when writing our own macros.
You'll have to edit each shadow tiddler to look at the definitions. Just click the discard-changes button when you're done so you don't mess anything up!go to answer