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
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)
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
def test_simple_minify(self): self.assertEqual(simple_minify(MINIFY_INPUT), MINIFY_EXPECTED)
def test_simple_minify(): assert simple_minify(MINIFY_INPUT) == MINIFY_EXPECTED