I prefer using the +[join[ ]]
technique, especially in examples, because it demonstrates the general technique for using filtered transclusions to assemble text from parts.
For a more complex use-case where the text is assembled from multiple parts, addsuffix[...]
(and/or addprefix[...]
) starts to become very verbose. Also, if some of the parts are not a simple text values or variable references, then you can’t always use addsuffix[]
… at least not easily.
For example, consider the case where you want to join some text that is retrieved from fields in some arbitrary tiddler whose title is stored in a variable like <myInput>
:
<$let sometext={{{ [[Hello]] [<myInput>get[first_name]] [<myInput>get[last_name]] +[join[ ]] }}}>
In contrast, to do this using addsuffix[]
you would need to get the first/last name values into variables and add the spaces between parts separately, like this:
<$let first={{{ [<myInput>get[first_name]] }}} last={{{ [<myInput>get[last_name]] }}}
<$let sometext={{{ [[Hello]addsuffix[ ]addsuffix<first>addsuffix[ ]addsuffix<last>] }}}>
and if the first_name
field was empty, you would end up with two adjacent spaces.
-e