Example #1
0
 def compress(parser, token):
     """
     Shadows django-compressor's compress tag so it can be
     loaded from ``mezzanine_tags``, allowing us to provide
     a dummy version when django-compressor isn't installed.
     """
     from compressor.templatetags.compress import compress
     return compress(parser, token)
Example #2
0
 def compress(parser, token):
     """
     Shadows django-compressor's compress tag so it can be
     loaded from ``mezzanine_tags``, allowing us to provide
     a dummy version when django-compressor isn't installed.
     """
     from compressor.templatetags.compress import compress
     return compress(parser, token)
def _fix_html_type(request, html, filetype):
    for group, files in requested_assets[request][filetype].items():

        # parse the content for the individual file tokens
        indices = []
        def sub_func(matchobj):
            indices.append(int(matchobj.group(2)))
            return ""

        regex = token_regexes[filetype][group]
        html = regex.sub(sub_func, html)

        # replace the 'replace me' tag with actual list of
        # 'tags' (ie <link href="foo.css">)
        file_html = u""
        uncompressible_html = u""
        for index in indices:
            fileObj = files[index]
            if fileObj.isCompressible():
                file_html += fileObj.render()
            else:
                uncompressible_html += fileObj.render()

        # try to use the provided 'compress' app to compress the output
        if hasattr(settings, 'COMPRESS') and settings.COMPRESS:
            # Currently this only supports the django-css app we use

            from django.template import Lexer,Parser,Token,TOKEN_TEXT
            file_html += "{% endcompress %}"
            lexer = Lexer(file_html, None)
            from compressor.templatetags.compress import compress
            file_html = compress(
                Parser(lexer.tokenize()),
                Token(TOKEN_TEXT, "compress " + filetype)
            ).render({})

        file_html = uncompressible_html + file_html
        tag = ASSET_DEFS[filetype]['destination_tag'].get(group, None)
        if tag:
            html = smart_unicode(html)
            html = html.replace(tag, file_html + tag)

    return html
Example #4
0
 def compress(parser, token):
     from compressor.templatetags.compress import compress
     return compress(parser, token)
Example #5
0
 def compress(parser, token):
     from compressor.templatetags.compress import compress
     return compress(parser, token)