'Method to pre-render the contents for the message template
@param resource: the S3Resource
@param data: the data returned from S3Resource.select
@param meta_data: the meta data for the notification
@param format: the contents format ("text" or "html")'

@classmethod
def _render(cls, resource, data, meta_data, format=None):

    created_on_selector = resource.prefix_selector('created_on')
    created_on_colname = None
    notify_on = meta_data['notify_on']
    last_check_time = meta_data['last_check_time']
    rows = data['rows']
    rfields = data['rfields']
    output = {}
    (new, upd) = ([], [])
    if (format == 'html'):
        colnames = []
        new_headers = TR()
        mod_headers = TR()
        for rfield in rfields:
            if (rfield.selector == created_on_selector):
                created_on_colname = rfield.colname
            elif (rfield.ftype != 'id'):
                colnames.append(rfield.colname)
                label = rfield.label
                new_headers.append(TH(label))
                mod_headers.append(TH(label))
        for row in rows:
            append_record = upd.append
            if created_on_colname:
                try:
                    created_on = row['_row'][created_on_colname]
                except (KeyError, AttributeError):
                    pass
                else:
                    if (s3_utc(created_on) >= last_check_time):
                        append_record = new.append
            tr = TR([TD(XML(row[colname])) for colname in colnames])
            append_record(tr)
        if (('new' in notify_on) and len(new)):
            output['new'] = len(new)
            output['new_records'] = TABLE(THEAD(new_headers), TBODY(new))
        else:
            output['new'] = None
        if (('upd' in notify_on) and len(upd)):
            output['upd'] = len(upd)
            output['upd_records'] = TABLE(THEAD(new_headers), TBODY(upd))
        else:
            output['upd'] = None
    else:
        labels = []
        append = labels.append
        for rfield in rfields:
            if (rfield.selector == created_on_selector):
                created_on_colname = rfield.colname
            elif (rfield.ftype != 'id'):
                append((rfield.colname, rfield.label))
        for row in rows:
            append_record = upd.append
            if created_on_colname:
                try:
                    created_on = row['_row'][created_on_colname]
                except (KeyError, AttributeError):
                    pass
                else:
                    if (s3_utc(created_on) >= last_check_time):
                        append_record = new.append
            record = []
            append_column = record.append
            for (colname, label) in labels:
                append_column((label, row[colname]))
            append_record(record)
        if (('new' in notify_on) and len(new)):
            output['new'] = len(new)
            output['new_records'] = new
        else:
            output['new'] = None
        if (('upd' in notify_on) and len(upd)):
            output['upd'] = len(upd)
            output['upd_records'] = upd
        else:
            output['upd'] = None
    output.update(meta_data)
    return output
