Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IDEA] Add macro operator #8732

Open
Leilei332 opened this issue Nov 8, 2024 · 5 comments
Open

[IDEA] Add macro operator #8732

Leilei332 opened this issue Nov 8, 2024 · 5 comments

Comments

@Leilei332
Copy link
Contributor

The current implementation of using macros in filters isn't good enough:

<$list filter="[<mymacro param:'value'>]">
...
</$list>

It isn't able to use variables or textreference as a parameter of the macro. I think we had better introduce a macro operator so that variables and textreference can be used as parameter (like the function operator). For example

<$list filter="[macro[mymacro],[value]]">
...
</$list>

<$let template="DDth MMM YYYY">
<!-- variables and textreference are allowed -->
{{{ [macro[now],<template>] }}}
{{{ [macro[now],{$:/config/NewJournal/Title}] }}}
</$let>
@pmario
Copy link
Member

pmario commented Nov 8, 2024

It would be sensible to name it procedure or proc and allow \procedure definitions and may be \defines too.

The most generic way would be transclude[variable],[param1] and so on. But we already have a transcludes operator so this will be very error prone.

@Leilei332
Copy link
Contributor Author

Leilei332 commented Nov 9, 2024

As is described in docs:

Procedure calls can be used in filters. The text is not wikified which again means that the parameters will be ignored.

So it isn't encouraged to use procedure with parameters in filters. IMO the operator should not support macros or procedures defined in tiddlers, it only makes sense to support javascript macros in filters.

@Jermolene
Copy link
Member

Hi @Leilei332 might another possibility be to update the existing function operator to be able to work with JS macros? At the moment, [function[now]] is broken.

@Leilei332
Copy link
Contributor Author

If we decided to extend the function operator to support javascript macros, we need to deal with the conflict of functions defined in tiddlers and javascript macros:

  1. Disallow functions which has the same name as a core javascript macro
  2. Allow overriding javascript macros

@Jermolene
Copy link
Member

Hi @Leilei332 I guess we already have the same conflict between functions and JS macros when using the <<name>> syntax, so perhaps we can make things consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants