Parameterized Transclusion: Function as Widget Attributes

  1. Open https://tiddlywiki.com/prerelease/parameterised-transclusions/
  2. Create a tiddler tagged with $:/tags/Macro with below content
\function cstyle()
[all[current]tag[Task]!tag[Done]then[color:red;]] :else[all[current]tag[Task]tag[Done]then[color:green;]]
\end cstyle

\define msg(str)
<div style=<<cstyle>> >
<<__str__>>
</div>
\end
  1. Now in another tiddler call msg for example
<<msg "Hello Parametrised Transclusion.">>
  1. tag tiddler with Task, the message is read
  2. tag tiddler with Task and then Done , the message is green

The function generates the right text color based on tags of current tiddler.

In TW before 5.3.0, you have to do this using filtered transclusion.

6 Likes