-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Dynamic parameters for macro/procedure/function calls #9055
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
base: master
Are you sure you want to change the base?
Conversation
The idea is to extend the macro call syntax to accept dynamic parameter values (ie thing:{{more}} etc). Eventually, this will work in all the contexts in which the double angle bracket syntax is valid.
This initial commit gets the tests passing, but doesn't yet activate the new functionality.
This fixes the tests
✅ Deploy Preview for tiddlywiki-previews ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Confirmed: Jermolene has already signed the Contributor License Agreement (see contributing.md) |
📊 Build Size Comparison:
|
| Branch | Size |
|---|---|
| Base (master) | 2528.4 KB |
| PR | 2534.9 KB |
Diff: ⬆️ Increase: +6.5 KB
|
IMO #8732 can be implemented, which is less complex and is consistent with functions in filters. |
|
@flibbles -- I think this one will have side effects on "relink plugins". Did you see this PR? Can you have a closer look. -- Just in case. |
|
It will have an effect on Relink, and Uglify. But I do see the value in making parameters and attributes more analogous. (Just wish we could get rid of the old way of doing things so we didn't have so much legacy syntax to support.) I'm not sure how I feel about that block syntax though. Would that work within attribute invocations or operator parameters? It seems like it would be pretty ugly to me. If you want blocks for macros, which I imagine is a rare case for pre-existing macros, couldn't someone could just use the I know I've been using blocks pretty heavily while I write TW5-Graph, but that's why I pretty much fully adopted the |
|
I think the "block parameters" are just an idea. I think they are not part of the PR at the moment. I am actually not sure, what it should be used for. In the end users will need dynamic text there. Which will make every thing complex again. IMO for real world projects a title-list and tiddlers is the way to go in the end. |
📊 Build Size Comparison:
|
| Branch | Size |
|---|---|
| Base (master) | 2448.3 KB |
| PR | 2453.9 KB |
Diff: ⬆️ Increase: +5.6 KB
✅ Change Note Status
All change notes are properly formatted and validated!
📝 $:/changenotes/5.4.0/#9055
Type: enhancement | Category: hackability
Release: 5.4.0
Dynamic parameters for macro/procedure/function calls
🔗 #9055
👥 Contributors: Jermolene
📖 Change Note Guidelines
Change notes help track and communicate changes effectively. See the full documentation for details.
779e1b3 to
5136e33
Compare
|
@linonetwo I disabled the Serialize/Attribute wikitext test because it is broken with the changes in this PR. Presumably the serializer needs to be updated to understand the new syntax? If you are able to fix it, could you propose the changes here? Many thanks |
|
Sure, let me PR to this branch, that is easy for me (or Claude4.5, but I will review it) Need to add more information in parser, so serializer could know how to deal with them. So it gradually become CST instead of AST I think. That is why I have to modify core to add serializer, instead of let it be a 3rd party plugin. |
Thanks @linonetwo |
* Revert "Temporarily disable a broken serializer test" This reverts commit b314430. * restore synamic parameter parse result * lint * lint * remove duplicate * Update core/modules/parsers/parseutils.js Co-authored-by: Copilot <[email protected]> * Update editions/test/tiddlers/tests/data/serialize/DynamicWidgetAttribute.tid Co-authored-by: Copilot <[email protected]> * Update editions/test/tiddlers/tests/data/serialize/DynamicWidgetAttribute.tid Co-authored-by: Copilot <[email protected]> * fix: mixed qouted and unquoted --------- Co-authored-by: Copilot <[email protected]>
|
@Jermolene reviewing the to do list for this PR, I think this can be merged for v5.4.0 as the main functionality is in place and and it represents a signficant step forwards in terms of usability. The only item that really should be implemented for this release is " Enforcing new syntax to only work with equals signs (currently equals and colon are considered equivalent)". All the others, like comments within widget attributes were only added to the to do list for this PR since they touch the same parts of the code, but are otherwise not connected. |
|
Thanks @saqimtiaz, I agree that it would be good to get it in. I'll have a look at the colon/equals sign issue. |
|
@Jermolene -- slightly OT -- ESLint specific info. It is possible to allow |
Hi @pmario I think that there are so few situations where JS code should include any |
|
|
Great, thanks @Jermolene. I will create issues for the deferred items like comments within filters and widget attributes. |
|
I believe we are only missing updated documentation now. |
I've updated the OP to identify the required docs updates - it is the railroad diagrams that will be a bit of a nuisance. |
Introduction
This PR makes an important change to the handling of macro calls by finally allowing parameters to be specified as dynamic transclusions instead of just constant strings.
In other words, by changing the usual colon into an equals sign it is now possible to do things like this:
Or even this:
Not to mention this:
We can even specify parameters for the inner call:
I am pleased about this change for obvious reasons: it removes a long-standing irregularity from TiddlyWiki's syntax, and it adds flexibility and expressiveness that will be appreciated by all wikitext authors.
The reason I am embarrassed is that it has taken so long to address this issue, particularly as it has turned out that the implementation is not enormously complex. In mitigation the changes in v5.3.0 laid a lot of the groundwork for this change.
Background
In fact, "macro calls" has become an increasingly ill-fitting term since v5.3.0 when the same syntax was extended to allow it to be used to invoke functions and procedures. I propose we use the term "call" to refer generally to all three formulations, and "macro call", "procedure call" and "function call" for the specific variants.
The call syntax can be used in three different settings:
In all cases, it is now possible to use an equals sign instead of a colon to allow parameter values to be passed as a transclusion, filter expression or nested call.
Backwards Compatibility
The backwards compatibility issues with this change are fairly extreme edge cases. In particular, previously a construction like this would have been interpreted as an unquoted parameter with the value "name=background":
So, this change will break code that invokes a macro with an unquoted parameter that contains an equals sign. There is no restriction on parameters with double or single quotes.
Progress
This PR is not yet complete: