'Create a text message using a template, message body and context.
Convert message body (`message_body`) into an email message
using the provided template.  The template is a format string,
which is rendered using format() with the provided `context` dict.
Any keywords encoded in the form %%KEYWORD%% found in the message
body are substituted with user data before the body is inserted into
the template.
Output is returned as a unicode string.  It is not encoded as utf-8.
Such encoding is left to the email code, which will use the value
of settings.DEFAULT_CHARSET to encode the message.'

@staticmethod
def _render(format_string, message_body, context):

    if (('user_id' in context) and ('course_id' in context)):
        message_body = substitute_keywords_with_data(message_body, context)
    result = format_string.format(**context)
    message_body_tag = COURSE_EMAIL_MESSAGE_BODY_TAG.format()
    result = result.replace(message_body_tag, message_body, 1)
    return wrap_message(result)
