[tw5] Parameters into macros

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 <> 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]"></$list></$vars> would work if it was a regular macro instead of a javascript macro. But, even though the parameter that can be fed is called days, it’s not picked up by the macro call.

Hopefully that makes sense - thanks

The first thing that comes to mind is rewriting the macro as a filter operator.

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.

Feel free to post here with your filter code (and of the macro) if you get stuck.