I like it! One minor caveat. For similar reasons to what you said in Struggling with Procedures,
can I suggest you leave the bold wikitext out of this field, then you get to choose it when you display it, not when you set it.
I think the addition of the colon addsuffix[: ]
belongs in the formatting, not in the general-purpose function. So:
...
\function fieldname-title() [<fieldname>sentencecase[]]
<!-- ^---- remove addprefix -->
...
<li><<fieldname-title>>: <<fieldname-value>></li>
<!-- ^---- here, not in function -->
...
On another topic, I know you’ve been playing with functions a lot. One thing that I know is common in TiddlyWiki that bothers me is nonlocality. It’s demonstrated above by the fact that the calls to fieldname-title
and fieldname-value
do not pass the field “fieldname”. Instead they reach out to the environment they’re running in to pick up these variables. This would be fine in a nested-function situation, but it bothers me when that doesn’t happen.
Whether this bothers others or not, it’s something I’d like to avoid in my own work. But is there an easy way to pass variables as parameters to the function calls? What I would like is something like this:
\function tagged.list(tag) [tag<tag>]
\function t.fields() [fields[]prefix[t]] -[[text]] -[[title]]
\function fieldname-title(fld) [<fld>sentencecase[]]
\function fieldname-value(fld) [all[current]get<fld>]
<$list filter="[tagged.list[HelloThere]]">
<$link/>
<ul>
<$list filter="[<currentTiddler>t.fields[]]" variable=fieldname>
<li><<fieldname-title <<fieldname>> >>: <<fieldname-value <<fieldname>> >></li>
</$list>
</ul>
</$list>
Put that fails syntactically. Is there a simple way to do this?