How to include a field value as a macro argument

Here’s what I’ve tried:

<<macro “{{!!field}}”>>

without and within a template.

Maybe i’m barking up the wrong tree. any approach that works, i’m trying to produce a URL .

For these kinds of macro references, I use the MacroCall Widget.

https://tiddlywiki.com/#MacroCallWidget

It also depends on how you made your macro, for example you could use text substitution:

\define macro(value)

<a href=$value$ >my link</a>

\end

<<macro "{{!!url}}">>

Personally I would rather use something like this :

\define macro(value)

<a href={{{ [subfilter<__value__>] }}} >my link</a>

\end

<<macro "[{!!url}]">>

That way if I want to use more elaborate filters I dont need to write the three curly brackets.

2 Likes

I prefer a more semantic syntax

<$macrocall $name=macro value={{!!url}} />

I tend to call macros with the macrocall widget,

  • But I tend to write macros where the “parameter is the fieldname, not the value”, and then get the value. I almost always write my macros to use the currentTiddler
  • This is only when the fieldname is not fixed, and I may want to use the same macro for more than one fieldname.
\define mymacro(fieldname)
<$set name=fieldvalue value={{{ [all[current]get[$fieldname$]] }}}>
  In here I use <<fieldvalue>> <<currentTiddler>> etc...
</$set>
\end
<<mymacro field>>