Calling a filed value literally, inside a filter?

51 views
Skip to first unread message

Mat

unread,
Jul 18, 2020, 2:28:43 PM7/18/20
to TiddlyWiki
myfield: <<foo>>
text
:
<$vars foo=bar>
{{!!myfield}}, is it prefixed "b"? {{{ [{!!myfield}prefix[b]then[YES!]] }}}
</$vars>

This gives result:

bar, is it prefixed "b"?

I was expecting 

bar, is it prefixed "b"? YES!

How can I make it work? It seems the field-invocation is evaluated when inside a filter but at that state its value (i.e <<foo>>) has no value - ?

Thanks!

<:-)

Mark S.

unread,
Jul 18, 2020, 3:41:00 PM7/18/20
to TiddlyWiki
This will do what you want:

<$vars foo=bar>
<$vars my1={{!!myfield}}>
<$wikify text={{!!myfield}} name=my2>
{{!!myfield}}, is it prefixed "b"? {{{ [
<my2>prefix[b]then[YES!]] }}}
</$wikify>
</$vars>
</$vars>

This will work whether myfield contains <<foo>> or "boo!".

Eric Shulman

unread,
Jul 18, 2020, 3:55:26 PM7/18/20
to TiddlyWiki
On Saturday, July 18, 2020 at 12:41:00 PM UTC-7, Mark S. wrote:
This will do what you want:
<$vars foo=bar>
<$vars my1={{!!myfield}}>
<$wikify text={{!!myfield}} name=my2>
{{!!myfield}}, is it prefixed "b"? {{{ [
<my2>prefix[b]then[YES!]] }}}
</$wikify>
</$vars>
</$vars>
This will work whether myfield contains <<foo>> or "boo!".

Note that in Mark's reply, the variable "my1" is not actually used, so it can be removed from the code:
<$vars foo=bar>

<$wikify text={{!!myfield}} name=my2>
{{!!myfield}}, is it prefixed "b"? {{{ [
<my2>prefix[b]then[YES!]] }}}
</$wikify>
</$vars>

The important idea here is this:

When you write {{!!myfield}} *outside* a filter, it automatically gets "wikified"
to *display* the correct value, "bar".

However, when you write {!!myfield} *inside* a filter, no wikification occurs,
so the value that is used is literally "<<foo>>".

Mark's solution uses the $wikify widget to explicitly convert the field value from
a variable reference to the *value* of that variable reference, and only then,
use that result within the filter.

-e

Mat

unread,
Jul 18, 2020, 5:03:05 PM7/18/20
to TiddlyWiki
Thanks guys, your help is much appreciated and it was news to me that {!!this} is not wikified inside a filter. Good to know!

I might have to come back on it though because it doesn't quite work in the actual context it is in. Too complex for me to explain though.

<:-)


Reply all
Reply to author
Forward
0 new messages