Return a literal or new title from a filter?

47 views
Skip to first unread message

TonyM

unread,
Sep 12, 2018, 10:08:44 PM9/12/18
to TiddlyWiki
Folks,

I am working on and idea to return status values for a given tiddler according to the result of a filter.

Most of you would be familiar with a filter such as this;

[<currentTiddler>has[item-completed]get[item-completed]]

Basically when the current tiddler has the field item-completed (containing a value) we Get the content of that field.

We can then display the content of  item-completed ONLY for tiddlers that meet the condition "has[item-completed]". Basically we say when this condition is true return this.

I was thinking what if we could simply return a literal, or title when the condition is true, so I Instinctively tried

[<currentTiddler>has[item-completed]title[completed]]

Hoping for this the return the value "completed" which may or may not be the title of a tiddler. Alas it does not work. It simply returns completed for every item in the list. The condition test is forgotten.

I have tried variations like
[<currentTiddler>has[item-completed]get{shortname!!item-completed}]
where the tiddler shortname has a field item-completed with the value "completed"

Unfortunately what I have tried so far always ignores the condition before hand 

There are plenty of "work around's", nested lists etc.. However such behaviour would be helpful

Does anyone know another way to return a value as a result of a condition in the middle of a filter?

Regards
Tony

Eric Shulman

unread,
Sep 12, 2018, 11:22:51 PM9/12/18
to TiddlyWiki
On Wednesday, September 12, 2018 at 7:08:44 PM UTC-7, TonyM wrote:
Does anyone know another way to return a value as a result of a condition in the middle of a filter?

Try this:
[<currentTiddler>has[item-completed]removeprefix<currentTiddler>addprefix[SOME_LITERAL_VALUE]]

let me know how it goes...

enjoy
-e

TonyM

unread,
Sep 13, 2018, 12:56:48 AM9/13/18
to TiddlyWiki
Eric,

Thanks, this is a great work around for, However I have potentially very large filters if I use this method. I would prefer to be able to use;

[<currentTiddler>has[item-completed]title[SOME_LITERAL_VALUE]]

Because I would like to have something like this

"[<currentTiddler>has[item-cancelled]title[Cancelled]] [<currentTiddler>has[item-completed]title[Completed]] [<currentTiddler>!has[item-cancelled]!has[item-completed]has[item-started]title[Started]]"

(So we get Cancelled and/or Closed) OR Started

Actually Thinking about this I need a more sophisticated macro.

Thanks for the working solution.

Regards
Tony
Reply all
Reply to author
Forward
0 new messages