I want to render a velocity template for my macro plugin. I placed the template in a folder under the resources folder. However, whenever I try to use the macro, this error shows up:
org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource path to velocity template
I even tried specifying the absolute path and it didn't work.
My code:
import com.atlassian.confluence.content.render.xhtml.ConversionContext;import com.atlassian.confluence.macro.Macro;import com.atlassian.confluence.macro.MacroExecutionException;import com.atlassian.confluence.util.velocity.VelocityUtils;import com.atlassian.confluence.renderer.radeox.macros.MacroUtils;
import java.util.Map;
public class MermaidLiveEditorMacro implements Macro {
public String execute(Map<String, String> map, String s, ConversionContext conversionContext) throws MacroExecutionException {
// do something with params ...
String code = map.get("Code");
String sampleDiagrams = map.get("Sample Diagrams");
Map context = MacroUtils.defaultVelocityContext();
context.put(map.get("Code"), code);
context.put(map.get("Sample-diagrams"), sampleDiagrams);
return VelocityUtils.getRenderedTemplate(absolute path to velocity template, context);
}
public BodyType getBodyType() { return BodyType.PLAIN_TEXT; }
public OutputType getOutputType() { return OutputType.BLOCK; }}
Take a look at this post , you have to ensure that the resource is added to the atlassian-pluin.xml file.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.