This issue has been created
 
 
XWiki Rendering / cid:jira-generated-image-avatar-9416d730-ec60-4229-898e-688ba9325a1f XRENDERING-747 Open

Support converting/changing macros during the macro transformation

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-f1937df0-39d0-44d1-a271-3504a6115446 Michael Hamann created this issue on 06/Jun/24 17:12
 
Summary: Support converting/changing macros during the macro transformation
Issue Type: cid:jira-generated-image-avatar-9416d730-ec60-4229-898e-688ba9325a1f Improvement
Affects Versions: 16.4.0
Assignee: Unassigned
Components: Transformation
Created: 06/Jun/24 17:12
Priority: cid:jira-generated-image-static-major-f25280e6-44e6-4793-9f18-6b6947b5738e Major
Reporter: Michael Hamann
Description:

It would sometimes be useful to have a way to convert a macro or its parameters in some way before it is executed in the macro transformation. As an example, imagine a macro transitions from having two field for specifying a document and an attachment name to having a single field for an attachment reference. In that case, it would be nice if the macro could, before it is executed, transform these two parameters into one such that this change is persisted in the macro marker block. This should have the following consequences:

  1. The macro execution itself directly gets the new parameter.
  2. When editing the macro in the WYSIWYG editor, the user sees the converted parameter and the inputs for the legacy parameters can be removed.
  3. When saving after editing in the WYSIWYG editor, the new parameter value(s) are saved.

In the same way, a macro should be able to indicate a macro it should be replaced with and perform a conversion of the parameters of the replacement. There should probably still be macros with both the old and the new name to handle things like execution priority but - depending on the actual implementation - the "old" macro might never be executed.

The easiest way to implement this would probably be some kind of preprocessing method in macros themselves (similar to the current prepare method, but with a guarantee that it will be executed and a way to change the macro's id), but this could also be implemented as a separate macro converter component.