How to create a button that can optionally add an extra tag?

44 views
Skip to first unread message

kat

unread,
Nov 24, 2019, 6:51:22 PM11/24/19
to tiddl...@googlegroups.com
I have created a template for a button and I'm trying to turn it into a macro that has the option to also add <<currentTiddler>> as a tag. It's not clear to me from the manual how to do this so I would really appreciate any help.

Here is a simplified example to illustrate what I mean. Say this is my button:

\define add-tiddler()
<$button><$action-sendmessage $message="tm-new-tiddler" title=<<now>> tags="tag1" />
New Tiddler
</$button>
\end

I'm trying to modify the macro so that <<add-tiddler tag:"false">> would run something like this:

<$action-sendmessage $message="tm-new-tiddler" title=<<now>> tags="tag1" />

While <<add-tiddler tag:"true">> would run this:

<$action-sendmessage $message="tm-new-tiddler" title=<<now>> tags="tag1 [[<<currentTiddler>>]]" />

I'm trying to avoid creating two separate templates/macros because my actual button code is pretty long and it will be awkward to have to edit both every time I want to make a change.

Thanks in advance for your help.

Mark S.

unread,
Nov 24, 2019, 7:39:10 PM11/24/19
to TiddlyWiki
Try

\define add-tiddler()
<$button>
<$vars lb="[[" rb="]]">
<$wikify name=tags text="tag1 <<lb>><<currentTiddler>><<rb>>">
<$action-sendmessage $message="tm-new-tiddler" title=<<now>> tags=<<tags>> />
New Tiddler
</
$wikify>
</$vars>
</
$button>
\end


<<add-tiddler>>


Reply all
Reply to author
Forward
0 new messages