For a while I am using the wonderful _printf[] filter from @saqimtiaz.
The plugin can be found here: Saq’s Sandbox — Experimental doodads (saqimtiaz.github.io)
The readme states:
_printf: Substitute variables and operands into strings, a friendler way of constructing strings from components.
It works like Python strings and makes life easy when you need to concatenate strings and create a compound string using macros, addsuffix, addprefix, …
Examples
Example i
<$vars name=Saq age=140>
<$text text={{{ [[My name is $(name)$ and $0$ my age is $(age)$.]_printf[I think]] }}}/>
</$vars>
produces
My name is Saq and I think my age is 140.
Remarks
- Here
nameandageare two variables - A number in the
$ $can be used to refer to the position of the object passed into the_printf.
Example ii
<$text text={{{ [[My name is $0$ and my age is $1$.]_printf[Saq],[100]] }}}/>
produces
My name is Saq and my age is 100.
Remarks
- Here
$0$refers to Saq and$1$refers to 100 in_printf[Saq],[100] - so the value /input to
_printfcan be refered by their positions.
Example iii
<$let baseTiddler=practice
tempTiddler={{{ [[$:/temp/$1$$0$]_printf<qualify>,<baseTiddler>] }}} >
<$edit-text tiddler=<<tempTiddler>> tag=input placeholder="input box ..."/>
;Debug
: temp tiddler title: <$link to=<<tempTiddler>> />
: temp tiddler content: <$transclude tiddler=<<tempTiddler>> />
</$let>
Remarks
- The
tempTiddleris created from concatenating a string, macro and variable - The
_printfrecives two objects here a macro and a variable:qualifyandbaseTiddler
To give a try
- Create an empty wiki (download one from http://tiddlywiki.com/)
- drag Saq's Sandbox — Experimental doodads and drop into empty wiki
- use any of above examples by copy - paste the code!