renderer and escaping HTML in GStringTemplateEngine

Hi All and Jamie

There's 'Send Custom Email' post-function in which we define mail subject and body using GStringTemplateEngine. I can put ${issue.description} or <%= issue.description %>, but how do I properly escape HTML tags given that we are bound to the processing template context? In Velocity Templates we'd use something like $textutils.htmlEncode.

Also, we may have a wiki renderer set to a field, in Velocity we'd play like $!{rendererManager.getRenderedContent("atlassian-wiki-renderer", $comment.body, $issue.issueRenderContext)}. How we'd run it from GStringTemplateEngine?

Cheers,
Oles

1 answer

This widget could not be displayed.

After struggling a bit with it looking at the sources found solution that works somehow:

&lt;%
def rendererManager = componentManager.getRendererManager()
def descriptionLayoutItem = componentManager.getFieldLayoutManager().getFieldLayout(issue).getFieldLayoutItem("description")
def descriptionRenderer = rendererManager.getRendererForField(descriptionLayoutItem)
%&gt;

and then

&lt;%= descriptionRenderer.render(issue.description, null)  %&gt;

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

161 views 1 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you