On Wednesday, April 29, 2020 at 1:42:49 PM UTC-7, Lisa Wasserman wrote:
>
> \define journalTiddlerName( ) <<now DD-MMM-YYYY>> $(project)$
>
Macros are text-substitution processors. As such, they only do two things:
1) replace parameters -- $paramname$ -- with the values passed to the macro
2) replace variables -- $(variablename)$ -- with the values currently
assigned by the calling context
After completing those replacements, the result is then inserted into the
calling context which determines how the macro result is handled.
In your code, you have three instances of the <<journalTiddlerName>> macro:
1) <$transclude tiddler=<<journalTiddlerName>> mode="block" />
2) <<journalTiddlerName>>
3) <$tiddler tiddler=<<journalTiddlerName>>>
In both the 1st and 3rd instances, the macro output is used as the value
for the "tiddler" parameter in a widget call and the macro output is simply
passed along to the widget for further handling.
In the 2nd instance, the macro output is actually being *displayed* and it
is directly parsed and rendered.
For your purposes, you want to actually evaluate the <<now ...>> macro and
then substitute it's output into the macro.
Here's a modified version of your code that should do what you want:
\define journalTiddlerName( ) $(when)$ $(project)$
\define state() $:/state/$(currentTiddler)$
<$vars project={{!!project}} when=<<now DD-MMM-YYYY>>>
<$reveal type="nomatch" state=<<state>> text="show">
<p><h2>Today <$button set=<<state>> setTo="show" class=
"tc-btn-invisible">{{$:/core/images/edit-button}}</$button></h2></p>
<p><$transclude tiddler=<<journalTiddlerName>> mode="block" /></p>
</$reveal>
<$reveal type="match" state=<<state>> text="show">
<p><h2>Today <$button set=<<state>> setTo="hide"
class="tc-btn-invisible">{{$:/core/images/done-button}}</$button></h2></p>
<<journalTiddlerName>>
<p><$tiddler tiddler=<<journalTiddlerName>>>{{||$:/core/ui/
EditTemplate/body/editor}}</$tiddler></p>
</$reveal>
</$vars>
notes:
* I used the <$vars> widget instead of separate <$set> widgets. It does
the same thing as $set (assigns values to variables), but is a more compact
syntax.
* I omitted the setting of the state variable, since it was just setting
the value to itself.
* I added a variable, "when" which captures the output of the <<now ...>>
macro.
* The "journalTiddlerName" macro then uses the $(when)$ reference to
substitute the captured "now" value into the desired result.
Give it a try and let me know how it goes...
enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)
InsideTiddlyWiki - http://TiddlyTools.com/InsideTW
<p><$transclude tiddler=<<journalTiddlerName>> mode="block" /></p>
> </$reveal>
> <$reveal type="match" state=<<state>> text="show">
> <p><h2>
> Today
> <$button set=<<state>> setTo="hide"
> class="tc-btn-invisible">{{$:/core/images/done-button}}</$button>
> </h2></p>
> <<journalTiddlerName>>
> <p><$tiddler tiddler=<<journalTiddlerName>>>
> {{||$:/core/ui/EditTemplate/body/editor}}
> </$tiddler></p>
> </$reveal>
> </$set>
> </$set>
>
> There are three calls to <<journalTiddlerName>>. The first and third
> return "<<now DD-MMM-YYYY>> WR-38972", while the second returns "
> 29-April-2020 WR-38972". For some reason, the Now macro is only working
> part of the time. Thoughts?
>
--
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/6c12adb2-fd8a-4c13-8e90-10657adfdcc6%40googlegroups.com.