Replace space in currentTiddler variable with underscore

42 views
Skip to first unread message

Ankit Mittal

unread,
Jun 15, 2020, 8:36:00 PM6/15/20
to TiddlyWiki
Hi,

I have been trying to get a variable set such that it has the title of current toddler without spaces. I tried following but it did not work...

\define testCreate()
<$set name=test filter=""" <<currentTiddler>> +[join[_]] """>
<<test>>
</$set>

\end

<<testCreate>>

If title of current tiddler is "Hello There Abbey", I was hoping above macro would result in Hello_There_Abbey but it did not.

What am I doing wrong and what can I do to achieve what I am after?

Eric Shulman

unread,
Jun 15, 2020, 9:17:55 PM6/15/20
to TiddlyWiki
On Monday, June 15, 2020 at 5:36:00 PM UTC-7, Ankit Mittal wrote:

I have been trying to get a variable set such that it has the title of current toddler without spaces. I tried following but it did not work...

\define testCreate()
<$set name=test filter="""  <<currentTiddler>> +[join[_]] """>
<<test>>
</$set>

\end

<<testCreate>>

If title of current tiddler is "Hello There Abbey", I was hoping above macro would result in Hello_There_Abbey but it did not.


Try this:
<$set name="test" filter="[<currentTiddler>split[ ]join[_]]">
<
<test>>
</$set>

You can also achieve the same results with the <$vars> widget, using an "inline filter", like this:
<$vars test={{{ [<currentTiddler>split[ ]join[_]] }}}>
<
<test>>
</$vars>

and, if you just want to *display* the value, you don't even need the $vars.  Just write:
<$text text={{{ [<currentTiddler>split[ ]join[_]] }}}/>

enjoy,
-e

TW Tones

unread,
Jun 16, 2020, 12:06:58 AM6/16/20
to TiddlyWiki
And if you want a link to a tiddler by the new name

{{{ [<currentTiddler>split[ ]join[_]] }}}

Just to fill out Eric's comprehensive answer.

Tony

Ankit Mittal

unread,
Jun 16, 2020, 3:46:27 AM6/16/20
to TiddlyWiki
Thanks Eric and Tony... very helpful indeed.
Reply all
Reply to author
Forward
0 new messages