Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Understand an excerpt of the macros.vm file in Jira

Arnold Godin October 10, 2019

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