Ejemplo n.º 1
0
 def process_response(self, request, response):
     header = 'Content-Type'
     if response.has_header(header) and 'text/html' in response[header]:
         try:
             response.content = simple_minify(response.content.strip())
         except:
             pass
     return response
Ejemplo n.º 2
0
def angular_template(context, template_name, angular_name):
    context.update({
        'angular_template_name': template_name,
    })
    content = ANGULAR_TEMPLATE.render(context)
    if not settings.DEBUG:
        content = mark_safe(simple_minify(content))
    context = template.Context({
        'template': content,
        'angular_name': angular_name,
    })
    return ANGULAR_SCRIPT_TEMPLATE.render(context)
Ejemplo n.º 3
0
    def process_response(self, request, response):
        """
        Process the response by minifying HTML.

        HTML is minified only when the response content type
        is HTML (e.g. contains ``'text/html'``).
        """
        header = 'Content-Type'
        if response.has_header(header) and 'text/html' in response[header]:
            try:
                response.content = simple_minify(response.content.strip())
            except Exception:
                pass
        return response
Ejemplo n.º 4
0
 def test_simple_minify(self):
     self.assertEqual(simple_minify(MINIFY_INPUT), MINIFY_EXPECTED)
Ejemplo n.º 5
0
def test_simple_minify():
    assert simple_minify(MINIFY_INPUT) == MINIFY_EXPECTED