Filter question: how to convert current tiddler title into a title list format

128 views
Skip to first unread message

Sebastián Ortega

unread,
Jun 22, 2021, 5:10:04 PM6/22/21
to TiddlyWiki
Hello wise tiddlywiki users,

Let's say I want to convert the current tiddler title into list format. For example:
  • For a tiddler named CamelCased, this is either CamelCased or [[CamelCased]] (I prefer the format but I can settle with the latter)
  • For a tiddler named Name with spaces it must be [[Name with spaces]]
I'm stuck with trying to add squared brackets conditionally [all[current]regexp[\s]addprefix[[[]addsuffix[]]]else{!!title}] because that's not the right syntax for adding the brackets and also because this feels common enough that it should be some easier way to "escape" a string to a title list format.

Do you know how to get it?

Sebastián Ortega

unread,
Jun 22, 2021, 5:18:55 PM6/22/21
to TiddlyWiki
I managed to fix the filter but I still feel there must be an easier way to do it.

<$vars prefix="[[" suffix="]]">
<$button>
<$action-sendmessage
    $message="tm-new-tiddler"
    source={{{ [all[current]regexp[\s]addprefix<prefix>addsuffix<suffix>else{!!title}] }}}
    author={{!!author}}/>
Add
</$button>
</$vars>

Saq Imtiaz

unread,
Jun 22, 2021, 5:33:08 PM6/22/21
to TiddlyWiki
For now that is the best we have.

However from the next TW release we can use format:titlelist[]
https://tiddlywiki.com/prerelease/#format%20Operator

PMario

unread,
Jun 22, 2021, 5:42:01 PM6/22/21
to TiddlyWiki
Hi,
See: https://tiddlywiki.com/#SetWidget   Especially the section: Filter List Variable Assignment
-mario


Jeremy Ruston

unread,
Jun 22, 2021, 5:52:10 PM6/22/21
to tiddl...@googlegroups.com
To expand on pmario’s answer:

<$vars prefix="[[" suffix="]]">
<$button>
<$set name="source" filter="[all[current]]">
<$action-sendmessage
    $message="tm-new-tiddler"
    source=<<source>>
    author={{!!author}}/>
Add
</$set>
</$button>
</$vars>

Best wishes

Jeremy

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/955e216d-ccc7-48b9-a438-aa883ac9d1d6n%40googlegroups.com.

TW Tones

unread,
Jun 22, 2021, 8:20:39 PM6/22/21
to TiddlyWiki
mehequeda,

I am curious why you need to do this. Since titles are the key to all tiddler there handling as titles is innate to TiddlyWiki and the need to generate a title with the delimiters [[ and ]] is rare. An example would be using the listops functions and operators where this is handled automatically. Tiddlywiki finds or adds delimiters automatically in many cases for title handling, consider  else{!!title} used in a filter, the output will not split a tiddler title containing spaces into separate words.

Regrads
Tones

Sebastián Ortega

unread,
Jun 23, 2021, 1:49:45 AM6/23/21
to tiddl...@googlegroups.com
Thanks Saq, Tones and Jeremy, it was hidden in plain sight.

The reason I need this is a design decision of some zettlekasten-like features I'm implementing in my wiki. For example, tiddlers tagged with Source are the books, articles, or other sources of concepts I want to track and I've modified the view template to show some fields and references to related things in a footer:
image.png
Now, I'm introducing buttons to create related tiddlers that have the kind of relationship of the corresponding tab. Sometimes that means copying current title in the author field. But in some case I need to set current title in title list format because of the meaning of the field. For example, a concept might have two authors.

BTW, this is pretty much inspired by the amazing Soren's zettlekasten. Thanks Soren!

--
Sebastián


--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/S5LM0L5ZVRo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/e971bff9-cdf0-407a-bc6b-e8b47580c36an%40googlegroups.com.

Joshua Fontany

unread,
Jun 23, 2021, 6:04:56 PM6/23/21
to TiddlyWiki
Hi mehequeda,

You will want to read up on the "ListOps": https://tiddlywiki.com/#ActionListopsWidget

Best,
Joshua Fontany
Reply all
Reply to author
Forward
0 new messages