I hope I did this reply correctly (I used reply all).

So I tried it out and for the sake of anyone else who might read this in 
the future here goes.

Trim works if written as   trim:prefix<prefix>  Thanks to both Eric and 
Matt for their response. 

As Eric mentions as given in the original post the filter will produce a 
single block of text that the trim sees as a single "word" to trim so only 
the leading [[ is  removed for trim prefix and the very last ]] is removed 
for the  trim suffix. If the enlist-input[] is included then the filter 
works as desired outputting a list of just the animal names with no 
brackets [[ ]] at all to be seen surrounding them. Thanks Eric for that. 
Also thank you for the explanation on bracketing in filter expressions. I 
knew of it but hadn't integrated it properly into my brain. This problem 
and your explicit mention of those syntaxes has now done that.

Thank you both
Regards
Sher


On Friday, December 17, 2021 at 11:29:51 AM UTC-5 Eric Shulman wrote:

> On Friday, December 17, 2021 at 7:54:00 AM UTC-8 [email protected] wrote:
>
>> ``` 
>>
> <$vars prefix="[[" suffix=" ]]">
>> <$list filter="[[smpConfig]get[animals]trim:prefix[<prefix>]]"/>
>> </$vars>
>> ```
>> If I don't have the trim part then the output is: [[Fox ]] [[Beaver 
>> ]]...  all good but once the trim is added there is no output.
>> So what silly error am I making?
>>
>
> A couple of things:
> 1) The brackets surrounding a filter operand are actually part of the 
> operand itself, and indicate the kind of operand to process:
>   * square brackets enclose literal values
>   * angle brackets enclose variable references
>   * curly braces enclose tiddler references
>
> Thus, you want to write: `trim:prefix<prefix>` instead of 
> `trim:prefix[<prefix>]`
>
> 2) The `get[foo]` syntax returns the value in the field named "foo" **as a 
> single block of text**.  To handle the retrieved value as a 
> space-separated, bracketed list of items, you should use the 
> `enlist-input[]` filter operator, like this:
>
> `<$list filter="[[smpConfig]get[animals]enlist-input[]"/>`
>
> 3) Your example list, retrieved from the field named "animals", seems to 
> include trailing space for each animal name.  I suggest omitting the extra 
> spaces in the field content.  Alternatively, you can use `trim:suffix[ ]` 
> in your filter, like this:
>
> `<$list filter="[[smpConfig]get[animals]enlist-input[]trim:suffix[ ]]"/>`
>
> enjoy,
> -e
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/fedfb31d-4871-4e56-8baa-1abcc4871c0fn%40googlegroups.com.

Reply via email to