XF 2.2 Using message_macros correctly...


I have some customized code in Templater that I'd like to move into message_macros. The previous Admin edited fnUserTitle, and added a custom badge he developed based on the user title:

$userTitleImage .= "<img src=\"/styles/rebelscum/ranks/".str_replace(' ','',$userTitle).".gif\" title=\"{$userTitle}\">";
return "<{$tag} class=\"userTitle{$class}\" dir=\"auto\"{$unhandledAttrs}>{$userTitleImage}</{$tag}>";

I would like to replicate this code in the macro area so that we don't have issues with upgrades in the future. Is there a pointer or two that someone can provide to assist me?

I assume this is the macro line that runs the function that was edited:

<xf:usertitle user="$user" tag="h5" class="message-userTitle" banner="true" itemprop="jobTitle" />