From bf41e08c2fd508a9cbc2c228d8c867dc0ddb91a6 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Thu, 6 Oct 2022 10:30:40 +0100 Subject: [PATCH] Revert change to setwidget docs --- editions/tw5.com/tiddlers/widgets/SetWidget.tid | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/editions/tw5.com/tiddlers/widgets/SetWidget.tid b/editions/tw5.com/tiddlers/widgets/SetWidget.tid index dbd8f70b3..fe05e8faa 100644 --- a/editions/tw5.com/tiddlers/widgets/SetWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/SetWidget.tid @@ -1,6 +1,6 @@ caption: set created: 20131115182700000 -modified: 20220909111836951 +modified: 20220523075522407 tags: Widgets title: SetWidget type: text/vnd.tiddlywiki @@ -54,6 +54,19 @@ src='<$set name=anotherVariable value="myVariable"> <<< +!! Conditional Variable Assignment + +This form of the set variable widget chooses one of two specified values according to whether a filter evaluates to an empty list. Here's an example that sets a variable according to whether the current tiddler is called "myMagicTitle": + +<<< + +<$macrocall $name='wikitext-example-without-html' +src="""<$set name="myVariable" filter="[all[current]field:title[myMagicTitle]]" value="It's magic" emptyValue="It's not magic"> +<$text text=<>/> +""" /> + +<<< + !! Filtered List Variable Assignment This form of the set variable widget evaluates the filter and assigns the result to the variable as a space-separated list (using double square brackets for titles containing spaces).