How to display the body of macro?

Teodor Tostovoy August 8, 2018

Hello everyone!

I am new at development macro, so I need help.

I've made a simple "container" macro with my custom styles (like as "info macro" etc). It has only to mark inputted text on pages. Now I need to display this macro at page, but my way doesn't work.

My Java-code is:

public String execute(Map map, String s, ConversionContext conversionContext) throws MacroExecutionException {
return VelocityUtils.getRenderedTemplate("templates/new-info-macro.vm", map);
}
public boolean hasBody()
{
return true;
}


@Override
public BodyType getBodyType()
{
return BodyType.RICH_TEXT;
}

@Override
public OutputType getOutputType()
{
return OutputType.BLOCK;
}

 VM: 

<div class="NewInfoBlock">
$body
</div>

When I put my macro in page in editing mode and insert some text in it, everything is OK. But when I update page I see only $body instead of inputted text.

Where is an error?

1 answer

1 accepted

0 votes
Answer accepted
Teodor Tostovoy August 8, 2018

Desicion:

 

public String execute(Map map, String body, ConversionContext conversionContext) throws MacroExecutionException {
map.put("body",body);
return VelocityUtils.getRenderedTemplate("templates/new-info-macro.vm", map);
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events