web_fragments/fragment.py
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
            elif resource.kind == "url":
                return u"<link rel='stylesheet' href='%s' type='text/css'>" % resource.data
            else:
                raise Exception("Unrecognized resource kind %r" % resource.kind)

        elif resource.mimetype == "application/javascript":
            if resource.kind == "text":
                return u"<script>\n%s\n</script>" % resource.data
            elif resource.kind == "url":
                return u"<script src='%s' type='application/javascript'></script>" % resource.data
            else:
                raise Exception("Unrecognized resource kind %r" % resource.kind)

        elif resource.mimetype == "text/html":
            assert resource.kind == "text"
            return resource.data

        else:
            raise Exception("Unrecognized mimetype %r" % resource.mimetype)
def resource_to_html(resource):
        if resource.mimetype == "text/css":
            if resource.kind == "text":
                return u"<style type='text/css'>\n%s\n</style>" % resource.data
            elif resource.kind == "url":
                return u"<link rel='stylesheet' href='%s' type='text/css'>" % resource.data
            else:
                raise Exception("Unrecognized resource kind %r" % resource.kind)

        elif resource.mimetype == "application/javascript":
            if resource.kind == "text":
                return u"<script>\n%s\n</script>" % resource.data
            elif resource.kind == "url":
                return u"<script src='%s' type='application/javascript'></script>" % resource.data
            else:
                raise Exception("Unrecognized resource kind %r" % resource.kind)

        elif resource.mimetype == "text/html":
            assert resource.kind == "text"
            return resource.data

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