Appending tiddler names (with spaces) via listops to a list from SelectWidget

194 views
Skip to first unread message

Stobot

unread,
May 18, 2018, 2:11:57 PM5/18/18
to TiddlyWiki
Hello all,

None of my usual tricks are helping me solve this problem. I want to have a <$select> list names (with spaces) and when the user chooses from the list, it's appended to a list - with the proper [[ ]] characters around it. It's the last [[ ]] part that's giving me problems. Normally I'd do a <$set> before the macro so I could pass to the macro to do the text substitution, but the text comes from the value of the <$select> itself, so there's nowhere I can get "in-between" to put that code... I'm sure I'm missing something easy here.

\define addmember()
<$action-listops $tiddler="$:/temp/newproject" $field="members" $subfilter=[[<<newmember>>]]/>
\end

Member List: {{$:/temp/newproject!!members}} + <$select tiddler="$:/temp/newproject" field="newmember" actions=<<addmember>>><$list filter="[tag[People]]"><option>{{!!title}}</option></$list></$select>

Any ideas? Also related - there's no way to do an <$action-...> within a <$select> other than through the "actions=" parameter right? Like a standalone command that you'd do with a <$button><$action-.../></$button>?

Mark S.

unread,
May 18, 2018, 3:20:55 PM5/18/18
to TiddlyWiki
This seems to work

\define addmember()
<$tiddler tiddler="$:/temp/newproject"><$action-listops $field="members" $subfilter="[{!!newmember}]"/></$tiddler>

\end

Member List: {{$:/temp/newproject!!members}} + <$select tiddler="$:/temp/newproject" field="newmember" actions=<<addmember>>><$list filter="[tag[People]]"><option>{{!!title}}</option></$list></$select>


HTH
-- Mark

Stobot

unread,
May 19, 2018, 8:09:01 AM5/19/18
to TiddlyWiki
Perfect! I was not thinking of the subfilter expression as a filter expression and was doubling my brackets [[{{ }}]] instead of [{ }] - rookie mistake. Note that while I put <<>> in my code above, that was a leftover from a previous dual-macro approach (whoops)

Thanks Mark!!

Rollo ro

unread,
Oct 22, 2018, 5:22:09 PM10/22/18
to TiddlyWiki
Hi,

@Mark: I spent countless hours with reading the documentation and trying to get the correct expression without success, and could finally get my code working after reading your post. Thanks for that!


I wanted to use

<$action-listops $subfilter={{$:/state/new-button-caption}} $field="myfieldoftitles"/>

to add an title which was typed in a text box. This failed for titles with spaces and I could not figure out how to get the [[ brackets without requiring the user to type it. Now I found that it works with

<$action-listops $subfilter="[{$:/state/new-button-caption}]" $field="myfieldoftitles"/>

This is much like what Mark posted. I just had to remove !! to be able to access my variable. This is what I understand, but I don't understand the rest of the syntax at all. I'd appretiate if someone could explain what the code actually means. Or how it is interpreted.

  

Mark S.

unread,
Oct 22, 2018, 5:41:20 PM10/22/18
to TiddlyWiki
The $subfilter attribute expects some type of filter to be handed to it. Unless your user types in an actual filter phrase, {{$:/state/new-button-caption}} won't work.

The filter string syntax allows transclusions inside the string with a single set of curly braces. So this:

  subfilter="[{$:/state/new-button-caption}]"

means take the value inside of $:/state/new-button-caption and insert it (transclude it) between the square brackets as though it were in-lined with it's own square brackets. So if tiddler $:/state/new-button-caption contained "My Exciting Tiddler" then the filter would see:

  subfilter="[[My Exciting Tiddler]]"

which is also the same as

  subfilter="[title[My Exciting Tiddler]]"


HTH
-- Mark

Rollo ro

unread,
Oct 23, 2018, 3:41:22 PM10/23/18
to TiddlyWiki
Hi,
it actually worked with the first code, as long as I typed a title without spaces. I don't know why.

It seems that there is a lack of important information in the documentation. I don't find anywhere that {variable} adds square brackets around the result, so I wasn't able to build the correct expression. With that piece of information, I understand it. Thanks!

In general the syntax is still very unclear to me. Can a definition be given what

{anything}

evaluates to, considering that anything itself can be a title, a variable, the result of another pair of curly brackets, etc? Because it seems that the brackets can have a totally different meaning and sometimes only one bracket is needed, and sometimes 2 or 3:

{$:/state/new-button-caption}
{{MyTiddler}}
{{{ [tag[mechanism]] }}}

I don't understand that logic.

Jed Carty

unread,
Oct 23, 2018, 4:07:59 PM10/23/18
to TiddlyWiki
A single set of curly braces is only used inside filters. It is the same as {{foo}} outside of filters in that it transcludes the content of foo. {{{ [tag[foo]] }}} is a shorthand for the list widget and is not actually related to the other uses.

The part that adds the square brackets has nothing to do with the { part, some operators treat any input as a title list and some widgets treat their output as a title list.

If an input is treated as a title list than any spaces will be used as separators between items unless it is surrounded by [[ and ]], and outputs from things that give title lists will put [[ and ]] around any items that have spaces in the name.

Mark S.

unread,
Oct 23, 2018, 4:11:01 PM10/23/18
to TiddlyWiki
As long as your input had no spaces, the result was interpreted as a tiddler title and worked fine as an input. Once you inserted spaces, it interpreted the result as a series of short tiddler titles (which didn't happen to exist).

There is a lot of documentation at TiddlyWiki.com, but it hasn't been unified into a friendly step-by-step guide. There are, several separate tiddlers that are nicely written. For instance,

"Introduction to filter notation"

if you read it to the bottom, it explains that you can use single curly brackets as a text reference. You can also use < and > for inserting variable values.

But this notation is different in some ways than other wikitext. Double curly brackets are used for simple transclusion:

{{HelloThere}}

Triple transclusions means to treat the inside part as a filter expression:

{{[tag[HelloThere]}}}

HTH
-- Mark

Rollo ro

unread,
Oct 23, 2018, 4:33:26 PM10/23/18
to TiddlyWiki
Thank you guys! This is a really good help and could also be very useful for other beginners.

TonyM

unread,
Oct 23, 2018, 5:37:32 PM10/23/18
to TiddlyWiki
Jed,

That is some helpful information speaking from Experience there. Perhaps I can add something?

I would add that when something is already delimited (its beginning and end indicated) it we do not need to go out of our way to delimit it. Especially with titles. eg in param={{tiddlername}}  tiddlername is already "bracketed", so param="{{tiddlername}}" is over kill and will return the literal string "{{tiddlername}}" not the content of tiddlername's text field.  I found this is not documented in https://tiddlywiki.com/#Macro%20Calls%20in%20WikiText and other places

Each parameter value can be enclosed in 'single quotes', "double quotes", """triple double quotes""" or [[double square brackets]]. Triple double quotes allow a value to contain almost anything. If a value contains no spaces or single or double quotes, it requires no delimiters.

Jed do you agree with the following?

If parameters are supplied using <<amacroorvariable>> a text reference {{tiddlername}} or a field in the current tiddler {{!!fieldname}} they are already delimited and need not be surrounded by quotes or [[double square brackets]]

The above is commonly done using the macrocall widget so that the parameters can be interpreted in the macrocall. The macro call allows you to name a macro, its parameters and provide parameters

Ie; you could say <<mymacro params>> but if you want to pass a param of <<myothermacro>> it will be difficult. So instead use the macrocall widget, so you can freely pass the parameters.

<$macrocall $name=mymacro param1=<<myothermacro>> />

Of note is in most cases except the wikify widget the value in a parameter will not be "wikified" so you CANNOT supply "compound values" in a parameter

eg param="MyPrefix/{{!!title}}" for example, because the parameter will not first be wikified to replace {{!title}} with its current value.

For this reason people tend to use macros, wikify and sometimes set to create a "compound value" to use as the parameter in a macro.

This was hard one knowledge, that now seems obvious to me but caused real problems for me in the beginning.

Criticisms of above statements welcome.

Regards
Tony

TonyM

unread,
Oct 23, 2018, 5:53:21 PM10/23/18
to TiddlyWiki
All,

I just realised the exception to creating "compound values" in parameters is when you are using $paramname$ $(paramname}$ and possibly
<<__...__>>


See


Regards
Tony
Reply all
Reply to author
Forward
0 new messages