[tw5] Re: Trim [[ or trim ]] not working
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 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 sheri...@gmail.com wrote: > >> ``` >> > <$vars prefix="[[" suffix=" ]]"> >> <$list filter="[[smpConfig]get[animals]trim:prefix[]]"/> >> >> ``` >> 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` instead of > `trim: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 tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/fedfb31d-4871-4e56-8baa-1abcc4871c0fn%40googlegroups.com.
[tw5] Re: Trim [[ or trim ]] not working
On Friday, December 17, 2021 at 7:54:00 AM UTC-8 sheri...@gmail.com wrote: > ``` > <$vars prefix="[[" suffix=" ]]"> > <$list filter="[[smpConfig]get[animals]trim:prefix[]]"/> > > ``` > 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` instead of `trim: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 tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/5c69419f-7444-4337-8f67-540795631edbn%40googlegroups.com.
[tw5] Re: Trim [[ or trim ]] not working
I didn't try out your code but it looks like a simple syntax error. Try: ... trim:prefix]"/> <:-) On Friday, December 17, 2021 at 4:54:00 PM UTC+1 sheri...@gmail.com wrote: > Hello > I am new to TW so I won't be surprised if the answer is obvious in > retrospect. > I have: > > <$vars prefix="[[" suffix=" ]]"> > <$list filter="[[smpConfig]get[animals]trim:prefix[]]"/> > > > 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? > > The intent behind this is as part of a larger activity (naturally) that > will take the resulting list of animals and find all tiddlers that have a > field with that animal name. A tiddler could have none, some or all of the > animal names as fields. I believe I can figure out the rest or at least > have fun trying but this trim problem has me beat. I have checked the > documentation, google searching and here to no avail. Help as they say > > Regards > Sher > > > -- 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 tiddlywiki+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/fd2bcb4e-3722-4e21-a95b-c95aee1a359an%40googlegroups.com.