Modify macro body by code

Hi,

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()
{
@Override
public void writeTo(final Writer writer) throws IOException
{
templateRenderer.renderTo(writer, “…”, “…”, data);
body.writeTo(writer);
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!