Struggling with reveal

88 views
Skip to first unread message

Simon

unread,
Sep 22, 2020, 7:46:26 PM9/22/20
to TiddlyWiki
Once again after hours of hacking I find myself turning to this board for some help

Background: I only want to show some particular data if the date in a field is BEFORE now

I have set a time stamp
<$set name="timestamp" value="<<now YYYY0MM0DD000000000>>">

This works fine, it's how to include that in the reveal
Here is what I have
<$reveal type='lt' state='!!gsd_duedate' text='<<timestamp>>' >

I have tried single angle brackets: <timestamp>, double angle <<timestamp>>, {{!!timestamp} and {!!timestamp} - all to no avail

I am clearly missing the syntax here. I know the field is set as I am able to display it using <<timestamp>> and if I hardcode the timestamp e.g. 20200922000000000 it works

Any help is gratefully appreciated

Thanks
Simon

Mark S.

unread,
Sep 22, 2020, 8:27:39 PM9/22/20
to TiddlyWiki
Well, this works with some caveats

<$set name="timestamp" value=<<now YYYY0MM0DD000000000>>>

<<timestamp>>

<$reveal type='lt' state='!!gsd_duedate' text=<<timestamp>> >
HI there
</$reveal>
</$set>

If there is any possibility that gsd_duedate will be empty, then you probably want to add extra checking for that. Actually I would probably scrap <reveal> and use <$list> since there are now comparison operators for filters. But I digress.

Also, by resetting the hours and minutes to all zeroes, you have effectively moved your timestamp BACK in time. This may make your reveal not trigger until X number of hours, where X depends on how close you are to the international date line.

Eric Shulman

unread,
Sep 22, 2020, 8:34:51 PM9/22/20
to TiddlyWiki
On Tuesday, September 22, 2020 at 4:46:26 PM UTC-7, Simon wrote:
I have set a time stamp
<$set name="timestamp" value="<<now YYYY0MM0DD000000000>
>">

<$reveal type='lt' state='!!gsd_duedate' text='<
<timestamp>>' >
I have tried single angle brackets: <timestamp>, double angle <<timestamp>>, {{!!timestamp} and {!!timestamp} - all to no avail

When specifying a widget parameter, the enclosing syntax is used to indicate the kind of parameter parsing to use:
  • "..." (or '...' or """...""" or [[...]]) is for literal values
  • <<...>> is for variables/macros
  • {{...}} is for tiddler/field references
  • {{{ [...] }}} is for filters
Thus, since <<now ...>> is a macro, and <<timestamp>> is a variable, they should not be enclosed in quotes:
<$set name="timestamp" value=<<now YYYY0MM0DD000000000>>>
<$reveal type='lt' state='!!gsd_duedate' text=<<timestamp>> >

Note that for simple assignments, you can use <$vars> instead of <$set>
<$vars timestamp=<<now YYYY0MM0DD000000000>>>

<$reveal type='lt' state='!!gsd_duedate' text=<<timestamp>> >

The advantage of <$vars> is that you can do multiple variable assignments in a single widget:
<$vars foo="literal" bar=<<macro>> baz={{!!field}} mumble={{{ [filter] }}}>

Note that the {{{ [filter] }}} syntax will only return one item from the filter (the *first* item).
To assign the results of a filter with multiple items, use <$set> with the "filter" parameter, like this:
<$set name="foo" filter="[...]">
also, you can use <$set> to perform "conditional assignment":
<$set name="foo" filter="[...]" value="has a result" emptyValue="no results">
If the filter returns a result, the specified value is used, if the filter returns no result, the emptyValue is used.

enjoy,
-e

Simon

unread,
Sep 23, 2020, 2:56:30 PM9/23/20
to TiddlyWiki
Awesome folks - once again some great help!
Very much appreciated
Simon

Reply all
Reply to author
Forward
0 new messages