@staticmethod
def resource_to_html(resource):
    """
        Returns `resource` wrapped in the appropriate html tag for it's mimetype.
        """
    if resource.mimetype == 'text/css':
        if resource.kind == 'text':
            return u"<style type='text/css'>\n%s\n</style>" % resource.data
        if resource.kind == 'url':
            return (u"<link rel='stylesheet' href='%s' type='text/css'>" %
                resource.data)
        raise Exception('Unrecognized resource kind %r' % resource.kind)
    if resource.mimetype == 'application/javascript':
        if resource.kind == 'text':
            return u'<script>\n%s\n</script>' % resource.data
        if resource.kind == 'url':
            return (
                u"<script src='%s' type='application/javascript'></script>" %
                resource.data)
        raise Exception('Unrecognized resource kind %r' % resource.kind)
    if resource.mimetype == 'text/html':
        assert resource.kind == 'text'
        return resource.data
    raise Exception('Unrecognized mimetype %r' % resource.mimetype)
