How to correctly use enlist?

[{!!__class}removesuffix[__Class]addsuffix[List::DefinedEvents]get[text]]

The filter above “read” the content of a tiddler which is composed of a serie of tiddler names like : [[XXX]] [[YYY]] [[ZZZ]]

I have uses this list into a <$select> widget like this:

<$set name="myList" filter="[{!!__class}removesuffix[__Class]addsuffix[List::DefinedEvents]get[text]]">
    <$select>
        <$list filter="[enlist<myList>]">
            <option value=<<currentTiddler>>><<currentTiddler>></option>
        </$list>
    </$select>
</$set>

The result is disturbing : the list displays 3 items : [[XX, YY and ZZ]].

  1. Where those brackets come from?
  2. How to correctly display XX, YY and ZZ?
  3. Is there a way to chain [{!!__class}removesuffix[__Class]addsuffix[List::DefinedEvents]get[text]] and enlist in the same filter?

Try this:

<$select>
   <$list filter="[{!!__class}removesuffix[__Class]addsuffix[List::DefinedEvents]get[text]enlist-input[]]">
      <option><<currentTiddler>></option>
   </$list>
</$select>

Notes:

  • enlist[...] is a “filter constructor”, which ignores any preceding filter values.
  • enlist-input[] is a “filter modifier”, which processes the preceding filter values as space-separated lists (i.e., converts a single text item, “XX YY ZZ”, into three separate items, XX, YY, and ZZ
  • Within HTML <option>...</option> syntax, if the option value is the same as the option display text, you can omit the value=... parameter. It will default to using the item display text as the value.
2 Likes

Thanks! I missed enlist-input[], which is exactly what I needed. :star_struck:

I still wonder why in my case extra brackets were added… :face_with_monocle: