% if ($Object->CurrentUserHasRight('SeeMemo')) {
<div class="memo-container" id="memo-container-<% $Name %>">
    <div class="memo-content" id="<% $Name %>" data-objectclass="<% ref($Object) %>" data-objectid="<% $Object->id %>"><% $Type eq 'text/html' ? $memo_content_html : $memo_linefeeds |n %></div>

%   if ($Object->CurrentUserHasRight('ModifyMemo')) {
    <textarea autocomplete="off" class="memo-edit-content<% $Type eq 'text/html' ? ' richtext' : '' %>" style="width: 100%" rows="<% $Height %>" <% $wrap_type |n %> name="<% $Name %>Edit" id="<% $Name %>Edit"><% $memo_value %></textarea>

%       if ($Type eq 'text/html') {
    <input type="text" style="display:none" name="<% $Name %>EditType" id="<% $Name %>EditType" value="<% $m->request_args->{$Name."Type"}||$Type %>" />
%       }
</div>
    <div class="submit" id ="MemoSubmit">
        <input type="submit" class="button" id="CancelMemo" name="CancelMemo" value="<% loc("Cancel") %>" data-action="Cancel" onclick="processMemoAction(this);" />
        <input type="submit" class="button" id="ActionMemo" name="ActionMemo" value="<% loc("Add a memo") %>" data-action="Add" onclick="processMemoAction(this);" />
    </div>
%   } else {
</div>
%   }
% }

<%INIT>
# Get initial value from attribute
my $memo_value = '';
$Object->ClearAttributes;
my $attr = $Object->FirstAttribute('Memo');
if ($Object->CurrentUserHasRight('SeeMemo') && $attr && $attr->Content && $attr->Content !~ /^\s*$/) {
    $memo_value = $attr->Content;
}
my $memo_content_html = $memo_value;
$memo_content_html =~ s/\n/<br \/>/g unless $memo_content_html =~ /<br \/>/;
my $memo_linefeeds = $memo_value;
$memo_linefeeds =~ s/\n/<br \/>/g;

# wrap="something" seems to really break IE + richtext
my $wrap_type = $Type eq 'text/html' ? '' : 'wrap="soft"';

</%INIT>
<%ARGS>
$Object
$Name    => 'MemoContent'
$Height  => RT->Config->Get('MemoHeight', $session{'CurrentUser'}) || 15
$Type    => RT->Config->Get('MemoRichText',  $session{'CurrentUser'}) ? 'text/html' : 'text/plain';
</%ARGS>
