Modify macro body by code


I’ve created a macro by java. Is there a way, to change the macro body by code? (and yes, I’m new in both Java and Confluence :slight_smile: )
I talk about StreamableMacro and it’s ‘Streamable executeToStream(final Map<String, String> parameters, final Streamable body, final ConversionContext conversionContext)’ method.

The original code (like Confluence’s Information macro):
return new Streamable()
public void writeTo(final Writer writer) throws IOException
templateRenderer.renderTo(writer, “…”, “…”, data);
templateRenderer.renderTo(writer, “…”, “…”, data);

I found two way:

  • change the macrodefinition in the conversationContext parameter, but in this case, the modification not visible in view mode
  • change the return value ‘body.writeTo(writer);’ part but in this case the modification not visible in edit mode

So, what is the solution to change the contetnt at one place that effect both edit and view mode?

Big thanks and have a nice day!