Parameters into macros

50 views
Skip to first unread message

Stobot

unread,
Aug 14, 2021, 12:54:22 PM8/14/21
to TiddlyWiki
Is there a way to pass dynamic parameters into macros (javascript) other than using <$macrocall/>? 

For instance I use a modified version of (Jed's I think) add-time.js that allows you to use a parameter 'days' to feed days to add to current date. So, doing something like <<add-time days:10>> would return the date 10 days from now. If it's a static number like 10, things are easy, but if it's dynamic (stored in a field) then things get more complicated - I have to use the <$macrocall/> instead, which is less convenient but sometimes not a problem. 

It becomes a problem when I need to use this new date in a filter. I *am* excited that in pre-release now we can feed *static* values as parameters into macros within filters, but the missing piece is still dynamic values as parameters - can't do a <$macrocall/> within a filter. 

If it's a normal macro, right now I'd surround the <$list/> with some <$wikify> runs that run the <$macrocall/>'s and wikify it to be fed in as a static value. I'm just wondering if there's a better way that I'm not thinking about (I end up with LOTS of wikify's which people tell me is not great). 

For instance, doing something like:
 <$vars days={{!!daystoadd}}><$list filter="[duedate<addtime>]"></$list></$vars> would work if it was a regular macro instead of a javascript macro. But, even though the parameter that <addtime> can be fed is called days, it's not picked up by the macro call. 

Hopefully that makes sense - thanks

Saq Imtiaz

unread,
Aug 14, 2021, 1:04:50 PM8/14/21
to TiddlyWiki
The first thing that comes to mind is rewriting the macro as a filter operator.

Adam Stobbe

unread,
Aug 14, 2021, 1:24:06 PM8/14/21
to tiddl...@googlegroups.com
Thanks Saq, actually that sounds like an interesting challenge. From a Javascript standpoint all I've done is tweak the macros of others so it may be a bit over my head, but I'll give it a try. 

--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/82fd0bc8-0322-4ef8-ba51-0b33342e8626n%40googlegroups.com.

Saq Imtiaz

unread,
Aug 14, 2021, 1:31:27 PM8/14/21
to TiddlyWiki
Feel free to post here with your filter code (and of the macro) if you get stuck.
Reply all
Reply to author
Forward
0 new messages