Showing sections matching a list of values

65 views
Skip to first unread message

Luis Gonzalez

unread,
Feb 21, 2020, 3:28:34 AM2/21/20
to TiddlyWiki
I have a section, <<simple-list>> that I want to show when the field "status" is fold or partial or order. Now I repeat the code three times:


\define my-macro()
<$reveal state="!!status" type="match" text="fold">
<<simple-list>>
</$reveal>

<$reveal state="!!status" type="match" text="partial">
<<simple-list>>
</$reveal>

<$reveal state="!!status" type="match" text="sort">
<<simple-list>>
</$reveal>

<!---------------------------IF status IS UNFOLD OR UNSORT, SHOW <<long-list>> INSTEAD-->
<$reveal state="!!status" type="status" text="unfold">
<<long-list>>
</$reveal>

<$reveal state="!!status" type="match" text="unsort">
<<long-list>>
</$reveal>
\end




Is there any way to make it easier?

Eric Shulman

unread,
Feb 21, 2020, 4:19:14 AM2/21/20
to TiddlyWiki
On Friday, February 21, 2020 at 12:28:34 AM UTC-8, Luis Gonzalez wrote:
I have a section, <<simple-list>> that I want to show when the field "status" is fold or partial or order. Now I repeat the code three times:
Is there any way to make it easier?

You can use the $list widget to check to see if the status field matches any a set of possible values.  Something like this:
\define my-macro()
<$list filter="[[fold]]   [[partial]] [[sort]] +[match{!!status}]"> <<simple-list>> </$list>
<$list filter="[[unfold]] [[unsort]]           +[match{!!status}]"> <<long-list>>   </
$list>
\end

enjoy,
-e
 

TonyM

unread,
Feb 21, 2020, 5:31:11 PM2/21/20
to TiddlyWiki
Eric,

Nice code. Using match after the possible values is economical, and works when only one value can be valid.

Regards
Tony
Reply all
Reply to author
Forward
0 new messages