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.
Templates and macros can both be used to include some content in multiple places. (We haven't seen how to create global macros yet so we don't have to write the same macro in every tiddler we use it in, but we'll get there soon. If you're curious, you can jump ahead now – you know everything you need to understand that section.) For instance, in the exercise where we created a template that showed a table of the fields on a meeting, we could just as well have written a macro:
\define meetingTemplate()
| !Time|{{!!at}}|
| !Participants|{{!!participants}}|
\end
For the most part, this is personal preference and a question of what makes the most sense semantically (that is, the two methods have the same effect, but one might be easier for a person to read and understand). Here are some points that might help you to decide between using a template and a macro:
ExerciseTemplate
to format each exercise; where the exercises appear, it simply says, e.g., {{Ex:CreateMeetingTemplate||ExerciseTemplate}}
for each exercise.<$set name=myvar1 value="xyz">
<$set name=myvar2 value={{!!field}}>
{{||MyTemplate}}
<<myMacro>>
</$set>
</$set>
In MyTemplate
, a reference to <<myvar1>>
will get the value xyz
, while in myMacro
, <<myvar1>>
or $(myvar1)$
will get the value xyz
. Similarly with myvar2
getting the value of field
on the current tiddler.
With a macro, you can also use the $macrocall
widget to pass field values as parameters.