>
> That last solution of mine did *not *have any macro. A macro is a 
> separate "codelet" that starts with "\definition". 
>  
>
>> OK, first, I agree that it *ought *to be possible to directly insert the 
>> color into the span thing. Again, my last solution did kind of do this. But 
>> there are a few issues with the code you write here above:
>>
>
> I'll get to your exact syntax but first, here is a syntax that is "more 
> correct but still faulty":
>
> ...
> Rating <span style="color:<<color>>">{{!!rating}}</span>
> ...
>
> The <<..>> syntax is the basic way to call a variable. I suspect this 
> doesn't work here because the span reads this one: <<color>>  as if it 
> was the closing angle bracket of the span tag. So this is why I, in my 
> initial solution, split out the whole span out into a macro.
>
> But you ask why $(...)$ doesn't work. This is because $(..)$ is the syntax 
> to call a variable when you are in a place where the variable was not 
> created. To see the difference, test this:
>
> \define mymacro()
> <$vars fruit=banana>
> This says banana: <<fruit>><br>
> This says apple: $(fruit)$
> </$vars>
> \end
>
> <$vars fruit=apple>
> This says apple: <<fruit>><br>
> <<mymacro>>
> </$vars>
>
> If you do this (no macro)
>
> <$vars fruit=apple>
> This says apple: $(fruit)$
> </$vars>
>
> ...you don't get anything because it is simply not the syntax to use when 
> calling the variable. It should be <<fruit>>.
>
> Your examples also imply a question on the difference between $list and 
> $vars. For this specific case, the output from the filter is only one value 
> so you can use either, as in your examples. $vars sets a variable to be a 
> specific value whereas $list sets a variable to be one value at a time from 
> a list of values.
>
> Hope this clarifies.
>
 
Hmmm... I think I get... some of that... me thinks.... :)  I also just 
thought that "define" is possible only as part of marco 
(https://tiddlywiki.com/#Pragma) and only one define per macro is possible 
(the one that starts at the very beginning of tiddler), but that's not that 
important.

In the end I decided to use your second option like:

\define rating()
<$vars style={{{ [{!!rating}compare:number:gteq[7]then[green]] 
~[{!!rating}compare:number:gteq[5]then[grey]] ~[[red]] +[addprefix[font-size: 
1.5em; font-weight: 500; color:]]" }}} >
<span style=<<style>>>{{!!rating}}</span>
</$vars>
\end


since 1 macro is better than 2 macros :)  and I can put any kind of css 
formatting inside the "addprefix" stuff.

But I have one more little questing, since we touched the Compare 
operator... I read this compare Operator 
<https://tiddlywiki.com/#compare%20Operator>, this Filter Syntax 
<https://tiddlywiki.com/#Filter%20Syntax> and this ListWidget 
<https://tiddlywiki.com/#ListWidget>, but I still don't get it... :)

I still have no idea *how to make compare operator work with field values 
inside a list widget?*

For example I have a list filtered by some tag and I want to add condition 
to show only tiddlers that have some date older than 20200701 and filter 
them by that date.
So if I have a working list

<$list filter="[tag[Comedy]!sort[releasedate]]> <$link/> |  </$list>

and I want to add additional filter condition. if to do it in accordance 
with the above example if should be smth like: 
[{!!releasedate}compare:date:gr[20200701]] 

but why doesn't this thing work:
<$list filter="[tag[Comedy]] +[{!!releasedate}compare:date:gr[20200701]] 
+[!sort[releasedate]]"> <$link/> |  </$list>  ?

I tried experimenting with brackets, but haven't managed to achieve 
anything. :(


 

-- 
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/9a3b9bc2-7a4e-4375-b952-cddf21e53871o%40googlegroups.com.

Reply via email to