one-liner to fetch tiddler's fields value

84 views
Skip to first unread message

CarloGgi

unread,
Jan 29, 2022, 4:12:09 PM1/29/22
to TiddlyWiki
Hallo everyone,
how do I write a one-line filter (a single filter expression) that outputs the value of all (or some of) the fields of a given tiddler? The more I try, the less I'm able to...

Thanks,
CG

Télumire

unread,
Jan 29, 2022, 8:11:49 PM1/29/22
to TiddlyWiki
{{{ [is[current]fields[]!match[text]]:reduce[<..currentTiddler>get<currentTiddler>format:titlelist[]addprefix[ ]addprefix<accumulator>]+[enlist-input[]] }}}

CarloGgi

unread,
Jan 30, 2022, 7:40:14 AM1/30/22
to TiddlyWiki
wow, awesome! Thanks a lot!

CarloGgi

unread,
Jan 30, 2022, 2:31:22 PM1/30/22
to TiddlyWiki
thanking again Télumire for his reply, I wonder now how to push things a little further and write a one-liner that outputs *pairs* of values, specifically, for each field of a given tiddler, the couple (field_name,field_value). I'm quite confident that to that aim the named prefix :map is the way to go, and indeed by using it it is easy to have at hand in its filter run both the tiddler's field names and their values. Still I fall short of joining these two data together somehow, so to have (field_name,field_value) as final output of the whole expression.

This code:

        {{{ [is[current]fields[]!match[text]]:map[<..currentTiddler>get<currentTiddler>] }}}

goes as near as I could go in trying to have the desired output, because it returns the tiddler's fields value; there is a little final step missing to have both the field name and value together...

Thanks for any help/suggestion/tip

CG

Télumire

unread,
Jan 30, 2022, 10:03:05 PM1/30/22
to TiddlyWiki
I think you want to use one of the default templates (or create your own) :

{{||$:/core/templates/tiddler-metadata}}

If you still want to use a filter expression you can use this :

{{{[is[current]fields[]!match[text]]:reduce[<..currentTiddler>get<currentTiddler>addprefix[: ]addprefix<currentTiddler>format:titlelist[]addprefix[ ]addprefix<accumulator>]+[enlist-input[]]}}}

or using your more elegant method :

{{{ [is[current]fields[]!match[text]]:map[<..currentTiddler>get<currentTiddler>addprefix[: ]addprefix<currentTiddler>] }}}

Télumire

unread,
Feb 1, 2022, 11:12:25 AM2/1/22
to TiddlyWiki
Better yet : {{||$:/core/ui/TiddlerFields}}
Reply all
Reply to author
Forward
0 new messages