create a button that mimics the behaviour of "Create a new tiddler tagged with this one"

173 views
Skip to first unread message

Ankit Mittal

unread,
Jun 27, 2019, 5:54:29 PM6/27/19
to TiddlyWiki
Hi, 

I am trying to create a button that mimics the behaviour of "Create a new tiddler tagged with this one". 

I used this 

<$action-sendmessage $message="tm-new-tiddler" text='<$transclude tiddler="$:/category">' tags={{!!title}} />

which works fine so long as title does not have white space but if it has white space it takes each word as a separate tag instead of making whole title the tag. 

Please can someone help me achieve this?

Mark S.

unread,
Jun 27, 2019, 6:11:32 PM6/27/19
to TiddlyWiki
Try

<$vars pre="[[" suf="]]">
<$button>New tiddler
<$action-sendmessage $message="tm-new-tiddler" text='<$transclude tiddler="$:/category">' tags={{{ [<currentTiddler>addprefix<pre>addsuffix<suf>] }}} />
</$button>
</$vars>

Ankit Mittal

unread,
Jun 28, 2019, 5:09:51 AM6/28/19
to tiddl...@googlegroups.com
Hi Mark. Many Thanks. It worked indeed. 

However, I must admit I do not follow the code .. what does <$vars> do and where should I read about it?

Actually thinking a bit more I guess I do understand what is happening::

  • <$vars is being used to declare variable pre and suf which are assigned the values "[[" and "]]"
  • Then I am assuming "addprefix" and "addsuffix" are keywords of some sort that helps add prefix and suffix using the variables declared using <$vars
  • So if the <currentTiddler> title was "Scary Books", then tags value becomes tags = [[[Scary Books]]] which syntactically is the way to tell it is one tag.
Thanks for helping me and please do correct my explanation above if I got it wrong. If not, please could you help me learn more on how I can get to know about the keywords like "addprefix" and "addsuffix" and similar...pointing me to a link where I can read will be hugely appreciated.

PMario

unread,
Jun 28, 2019, 6:44:34 AM6/28/19
to TiddlyWiki

Watt

unread,
Jun 28, 2019, 6:48:18 AM6/28/19
to TiddlyWiki
Hi Ankit

The docs on the official site have some info and examples:
https://tiddlywiki.com/#addsuffix%20Operator

https://tiddlywiki.com/#addprefix%20Operator

https://tiddlywiki.com/#VarsWidget:VarsWidget

If you find them a bit sparse you could try TWScripts for more examples;

https://kookma.github.io/TW-Scripts/#Filter%20Returns%20Only%20the%20First%20suffix%20word

https://kookma.github.io/TW-Scripts/#Simple%20Comparison%20of%20Two%20Variables

or sometimes searching the forum here is the best source of inspiration. They're generally pretty good at answering questions too, whatever the level, from beginner to expert. Good luck.

Xavier Cazin

unread,
Jun 29, 2019, 10:49:15 AM6/29/19
to tiddl...@googlegroups.com
Hi Ankit,

In order to get a tiddler title instead of a flat string, you usually want to retrieve it from a filter. You can use Mark's construct to build the tiddler title manually, but the <$set> widget does have a handy filter attribute that you can use directly, like so:

<$set name=foo filter='[{!!title}]'>
<$button><$action-sendmessage $message="tm-new-tiddler" text='<$transclude tiddler="$:/category">' tags=<<foo>> />Go!</$button>
</$set>

Regards,
Xavier.


Le ven. 28 juin 2019 à 11:09, Ankit Mittal <mr.anki...@gmail.com> a écrit :
Hi Mark. Many Thanks. It worked indeed. 

However, I must admit I do not follow the code .. what does <$vars> do and where should I read about it?

On Thursday, June 27, 2019 at 11:11:32 PM UTC+1, Mark S. wrote:
Try

<$vars pre="[[" suf="]]">
<$button>New tiddler
<$action-sendmessage $message="tm-new-tiddler" text='<$transclude tiddler="$:/category">' tags={{{ [<currentTiddler>addprefix<pre>addsuffix<suf>] }}} />
</$button>
</$vars>


On Thursday, June 27, 2019 at 2:54:29 PM UTC-7, Ankit Mittal wrote:
Hi, 

I am trying to create a button that mimics the behaviour of "Create a new tiddler tagged with this one". 

I used this 

<$action-sendmessage $message="tm-new-tiddler" text='<$transclude tiddler="$:/category">' tags={{!!title}} />

which works fine so long as title does not have white space but if it has white space it takes each word as a separate tag instead of making whole title the tag. 

Please can someone help me achieve this?

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/a96a87f0-c0d8-4f4f-8ce7-b21605bf9d9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

TonyM

unread,
Jun 29, 2019, 9:13:13 PM6/29/19
to TiddlyWiki
Nice tip Xavier

Ankit Mittal

unread,
Jun 30, 2019, 4:10:26 AM6/30/19
to tiddl...@googlegroups.com
Thanks a lot guys. Very helpful links and the set widget suggestion triggers few new ideas too. 

passingby

unread,
Jun 30, 2019, 12:01:08 PM6/30/19
to TiddlyWiki
I ran into this problem a while ago and someone from here in the group suggested this: 

\define getTag()
[[$(currentTiddler)$]]
\end

and now call this macro in the button:

<$action-sendmessage $message="tm-new-tiddler" text='<$transclude tiddler="$:/category">' tags=<<getTag>> />



On Thursday, June 27, 2019 at 2:54:29 PM UTC-7, Ankit Mittal wrote:

TonyM

unread,
Jun 30, 2019, 7:16:58 PM6/30/19
to TiddlyWiki
Passing by

I am curious if you have a particular reason to use

text='<$transclude tiddler="$:/category">'

Rather than

text={{$:/category}}

regards
Tony

passingby

unread,
Jul 1, 2019, 11:27:01 AM7/1/19
to tiddl...@googlegroups.com
TonyM,

I just copied that code line from OP's question and added the call to getTag macro, but, yes I think It should be {{$:/category}}
Reply all
Reply to author
Forward
0 new messages