Unlike most programming/scripting languages, TiddlyWiki wikitext syntax is, by default, sensitive to whitespace. As such, the presence of newlines and indentation can affect the rendered output. With regard to the TWCore shadow tiddlers, some of the (lack of) formatting in the “source code” is due to this sensitivity to whitespace.
One way to address this is to add the \whitespace trim
pragma at the beginning of the content (either the start of the tiddler, or within a specific macro definition). However, this needs to be done carefully, as there are some cases where whitespace is still required in order to correctly render the output. For most (but not all) of these cases, it is possible to make small changes to the wikitext (such as surrounding content with <div>...</div>
) to achieve the correct rendering without relying upon the whitespace parsing rules.
With regard to $set
vs $vars
vs $let
:
$set
was the original “assign a value to a variable” widget. Each assignment needed a separate $set
widget, like this:
<$set name="a" value="5">
<$set name="b" value="2">
<$set name="c" value={{{ [<a>multiply<b>] }}}>
The $vars
widget was then created to permit multiple variables to be set at the same time, but all assignments were done simultaneously, so if one variable depended upon another, you still needed to split them into separate $vars
widgets, like this:
<$vars a="5" b="2">
<$vars c={{{ [<a>multiply<b>] }}}>
The newest widget, $let
, also allows multiple assignments in a single widget, but they are evaluated in sequence, so that variables that are assigned later in the same $let
widget can refer to the values of previously assigned variables, like this:
<$let a="5" b="2" c={{{ [<a>multiply<b>] }}}>
Note: while $let
is now the preferred widget for simple variable assignements, $set
has other forms that are still useful, such as capturing filter results (as a space-separated, bracketed list) into a variable, like this:
<$set name="tids" filter="[tag[sometag]]">
or performing "conditional assignment, like this:
<$set name="hastag" filter="[tag[sometag]]" value="tag found" emptyValue="tag not found">
Hope this helps,
-e