[TW5] Using variables in a macro

61 views
Skip to first unread message

Chong

unread,
May 17, 2015, 10:18:12 AM5/17/15
to tiddl...@googlegroups.com
Each topic that I want an article on has several sections, and I break these up into tabs. For example if I want an article about zebras, I'll have separate tiddlers for their physical characteristics, their behaviour, and diet, and then the "Zebra" tiddler just contains all the others in tabs. So this'll just consist of:

<<tabs "[[Zebra - diet]] [[Zebra - behaviour]] [[zebra - physical characteristics]]">>

Problem is I'm going to be writing a lot of these (and there's more than 3 tabs), and I don't want to fill in the name of the animal every time. 
I want to make a template like this:

<<tabs "[[<<title>> - diet]] [[<<title>> - behaviour]] [[<<title>> - physical characteristics]]">>

But it obviously doesn't work (please forgive my ignorance). Anyone know how to do this?

Eric Shulman

unread,
May 17, 2015, 1:17:56 PM5/17/15
to tiddl...@googlegroups.com
You can create a macro that takes the animal name as a parameter, and then invokes the <<tabs>> macro using that param value, like this:

\define animaltabs(animal)
<<tabs "[[$animal$ - diet]] [[$animal$ - behaviour]] [[$animal$ - physical characteristics]]">>
\end

Then, just call it like this:
<<animaltabs Zebra>>
<<animaltabs Monkey>>
<<animaltabs Lion>>
etc.

enjoy,
-e
Eric Shulman
ELS Design Studios
TiddlyTools - "Small Tools for Big Ideas!"
InsideTiddlyWiki: The Missing Manuals

YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:

Reply all
Reply to author
Forward
0 new messages