This page last changed on Jan 24, 2006 by jnolen.

Cannot resolve external resource into attachment. What's the easiest way to render a velocity template from Java code?

Use VelocityUtils. You will need to provide VelocityUtils with the name of the template you want to render, and a map of parameters that will be made available within the template as $variables in velocity.

Confluence has a default set of objects for Confluence velocity templates. These are required for most Confluence velocity macros to work properly. To obtain this context, you should call MacroUtils.defaultVelocityContext();.

// Create the Velocity Context
HashMap context = MacroUtils.defaultVelocityContext();
context.put("myCustomVar", customVar);
context.put("otherCustomVar", otherCustomVar);
// Render the Template
String result = VelocityUtils.getRenderedTemplate("/com/myplugin/templates/macro.vm", context);

VelocityUtils is marked as deprecated, where can I find it's replacement?

Posted by alainmoran at Jan 31, 2006 06:59

Hi Alain,

Use com.atlassian.confluence.util.velocity.VelocityUtils

Jeremy

Posted by jeremy@atlassian.com at Feb 02, 2006 18:36
Document generated by Confluence on Mar 22, 2007 21:00