It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Understand an excerpt of the macros.vm file in Jira

Hello guys,

Is someone able to explain me excerpts of the macros.vm file

Context  : macros.vm was customized by the client, I dont' really know the purpose of this change, but then issue type icon didn't render properly in email generated by Jira. They are using Email This Issue plugin.

Basically, there was no problem with icons showing in Jira itself on boards or query results but just on emails.

To fix this, we simply reseted the macros.vm (out of the box version).

I understand the purpose of this file but I don't understand the code : 

 

Part 1 : 

## Renders the HistoryMetadataParticipant's info
#macro(emailHistoryMetadataParticipant $participant, $html)
    #set($participantId = $metadataHelper.getParticipantName($participant))
    #if($participantId)
        #if ($html)
        #if($participant.url)<a href="$textutils.htmlEncode($participant.url)">$textutils.htmlEncode($participantId)</a>#else$textutils.htmlEncode($participantId)#end
        #else
        $velocityhelper.removeHtmlTags($participantId)
        #end
    #end
#end## Renders the title header text for text emails - uses a passed i18ned string by default, replacing with metadata if appropriate
## Indentation is kept as comment so that in text emails does not get mixed up
#macro (headerTitleText $defaultMessage $authorName)
#if ("$!authorName" == "")
#* *##set($defaultMessage = "")
#end
#if($i18n.isKeyDefined($changelogmetadata.emailDescriptionKey))
#* *##if ("$!changelogauthor" != "" || "$!changelogmetadata.actor" == "")
#*   *##set ($metadataactor = $authorName)
#* *##else
#*   *##set ($metadataactor = "#emailHistoryMetadataParticipant($changelogmetadata.actor, false)")
#* *##end
#* *##set ($metadatagenerator = "#emailHistoryMetadataParticipant($changelogmetadata.generator, false)")
#* *##set ($metadatacause = "#emailHistoryMetadataParticipant($changelogmetadata.cause, false)")
#* *##set ($textHeaderTitle = $i18n.getText($changelogmetadata.emailDescriptionKey, $metadataactor.trim(), $metadatagenerator.trim(), $metadatacause.trim()))
#elseif($changelogmetadata.emailDescription)
#* *##set ($textHeaderTitle = "$defaultMessage $velocityhelper.removeHtmlTags($changelogmetadata.emailDescription)")
#else
#* *##set ($textHeaderTitle = "$defaultMessage")
#end
$!textHeaderTitle.trim()
#dashes($!textHeaderTitle.trim())
#end## Sets the header title for html emails, using the default i18n string or metadata as appropriate
#macro(setHeaderTitle $defaultMessage $authorLink)
    #if($i18n.isKeyDefined($changelogmetadata.emailDescriptionKey))
        #if ("$!changelogauthor" != "" || "$!changelogmetadata.actor" == "")
            #set ($metadataactor = $authorLink)
        #else
            #set ($metadataactor = "#emailHistoryMetadataParticipant($changelogmetadata.actor, true)")
        #end
        #set ($metadatagenerator = "#emailHistoryMetadataParticipant($changelogmetadata.generator, true)")
        #set ($metadatacause = "#emailHistoryMetadataParticipant($changelogmetadata.cause, true)")
        #set ($headerTitle = $i18n.getText($changelogmetadata.emailDescriptionKey, $metadataactor.trim(), $metadatagenerator.trim(), $metadatacause.trim()))
    #elseif($changelogmetadata.emailDescription)
        #set ($headerTitle = "$defaultMessage $textutils.htmlEncode($changelogmetadata.emailDescription)")
    #else
        #set ($headerTitle = $defaultMessage)
    #end
#end

Part 2 : 

#macro(renderIssueTypeIcon $issueType)<img src="$attachmentsManager.getIssueTypeIconUrl($issueType)" height="16" width="16" border="0" align="absmiddle" alt="$textutils.htmlEncode(${issueType.getNameTranslation($i18n)}, false)">#end

 

These 2 parts were missing in their customized macros.vm file.

Let me know if you need more information. I just need explanation for the code.

Thanks a lot!

Arnold G

 

0 answers

Suggest an answer

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

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

308 views 1 3
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you