On Thursday, September 10, 2020 at 1:30:39 AM UTC-7, talha131 wrote:
>
> Eric, why do we need three braces? {{{ What do they do in this example?
>

Double curly braces {{...}} is used for "transclusion" where you specify a 
tiddler title/field and/or a tiddler template.

Tripled curly braces {{{  }}} is used  for "filtered transclusion" where 
you specify a filter that computes one or more tiddler titles.

Either syntax can be used as the parameter value for a widget such as 
<$vars>
Doubled braces fetch a stored value from a field.
Tripled braces compute a value by evaluating a filter.

{{bar}}
gets the value from the "text" field of tiddler "bar"
{{bar!!mumble}} or {{{ [{bar!!mumble}] }}} or {{{ [[bar]get[mumble]] }}}
get the value from the "mumble" field of tiddler "bar"
{{!!mumble}} or {{{ [{!!mumble}] }}} or {{{ [get[mumble]] }}}
gets the value from the "mumble" field of the current tiddler

The big advantage of the tripled braces ("filtered transclusion") is that 
you can apply more filter syntax that just "get", such as "else".  Thus:
{{{ [get[mumble]else[gronk]] }}}
gets the value from the "mumble" field of the current tiddler... but if 
that field doesn't exists or has no value, it uses the literal text "gronk" 
instead.
{{{ [get[mumble]else{!!gronk}] }}}
gets the value from the "mumble" field of the current tiddler... but if 
that field doesn't exists or has no value, it uses the value from the 
"gronk" field instead.

You can also use other filter syntax, to create some pretty complex logic.  
Thus:
{{{ [get[mumble]removesuffix[arglebargle]else{!!mumble}] }}}
gets the value from the "mumble" field of the current tiddler AND removes 
the text "arglebargle" from the end of that value... but if that value 
doesn't end with "arglebargle", it just uses the value of "mumble", as-is.
{{{ [get[mumble]else[0]add[1]min[20]] }}}
gets the value from the "mumble" field of the current tiddler, then adds 1 
to that value, but never goes over 20.  Note: if "mumble" doesn't exist or 
is blank, a default value of "0" is used, and then 1 is added.

So... using that last example, you can create a button that counts from 1 
to 20, incrementing each time the button is pressed:
<$button> count
   <$action-setfield mumble={{{ [get[mumble]else[0]add[1]min[100]] }}} />
</$button>
mumble={{!!mumble}}

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/e6ca99a8-ac8a-487c-abf9-b28c8a591ac1o%40googlegroups.com.

Reply via email to