Hi.
I found many questions and answers about velocity templates in Confluence. And what about JIRA?
I have tried example from this page:
// Create the Velocity Context Map context = MacroUtils.defaultVelocityContext(); context.put("myCustomVar", customVar); context.put("otherCustomVar", otherCustomVar); // Render the Template String result = VelocityUtils.getRenderedTemplate("/com/myplugin/templates/macro.vm", context);
but I cannot find appropriate packages for MacroUtils and VelocityUtils in JIRA.
What packages I need to user for it? Or does exists anything else way to use velocity templates in JIRA?
Thanks.
To use Velocity Template you need:
For example:
@Scanned
public class MyClass {
@ComponentImport
private final TemplateRenderer templateRenderer;
public MyClass(TemplateRenderer templateRenderer) {
this.templateRenderer = templateRenderer;
}
}
After that you can use it, for example
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
Map<String, Object> context = Maps.newHashMap();
resp.setContentType("text/html;charset=utf-8");
context.put("key", "value");
templateRenderer.render("path_to_vm_template", context, resp.getWriter());
}
Hi Yanduganov,
You'll want to use the JIRA templates and JSP's guide for Velocity Templates in JIRA. MacroUtils and VelocityUtils appear to be for Confluence per the Confluence Velocity template documentation and I was unable to find references to those methods in the JIRA docs.
Cheers,
Branden
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
great doc, saves a lot of time, thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Branden.
Your answer isn't about templates which I meant.
I write JIRA plugin and I have servlet. And I wanna render it using velocity template. I tryed write HTML just in java but I think that it's a wrong way.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.