def testGuessHTMLorXHTML(self): code = """<ul> <li>One</li> <li>Two</li> </ul>""" self.assertEqual(slimmer.guessSyntax(code), 'html') code = """ <a href="foo.html"><img src="foo.jpg" /></a> """ self.assertEqual(slimmer.guessSyntax(code), 'xhtml')
def testGuessSyntax(self): for var, value in list(globals().items()): syntax = None if var.find('CSS')> -1: syntax = slimmer.guessSyntax(value) self.assertEqual(syntax, 'css') elif var.find('JS')> -1: syntax = slimmer.guessSyntax(value) self.assertEqual(syntax, 'js') elif var.find('HTML')> -1: syntax = slimmer.guessSyntax(value) self.assertTrue(syntax in ('html','xhtml')) else: continue
def testGuessSyntax(self): for var, value in globals().items(): syntax = None if var.find('CSS')> -1: syntax = slimmer.guessSyntax(value) self.assertEqual(syntax, 'css') elif var.find('JS')> -1: syntax = slimmer.guessSyntax(value) self.assertEqual(syntax, 'js') elif var.find('HTML')> -1: syntax = slimmer.guessSyntax(value) self.assertTrue(syntax in ('html','xhtml')) else: continue
def render(self, context): code = self.nodelist.render(context) if self.format == 'css': return css_slimmer(code) elif self.format in ('js', 'javascript'): return js_slimmer(code) elif self.format == 'html': return html_slimmer(code) else: format = guessSyntax(code) if format: self.format = format return self.render(context) return code
def render(self, context): code = self.nodelist.render(context) if slimmer is None: return code if self.format not in ('css','js','html','xhtml'): self.format = guessSyntax(code) if self.format == 'css': return css_slimmer(code) elif self.format in ('js', 'javascript'): return js_slimmer(code) elif self.format == 'xhtml': return xhtml_slimmer(code) elif self.format == 'html': return html_slimmer(code) return code
def render(self, context): code = self.nodelist.render(context) if slimmer is None: return code if self.format not in ('css','js','html','xhtml'): self.format = slimmer.guessSyntax(code) if self.format == 'css': return slimmer.css_slimmer(code) elif self.format in ('js', 'javascript'): return slimmer.js_slimmer(code) elif self.format == 'xhtml': return slimmer.xhtml_slimmer(code) elif self.format == 'html': return slimmer.html_slimmer(code) else: raise TemplateSyntaxError("Unrecognized format for slimming content") return code
def render(self, context): code = self.nodelist.render(context) if slimmer is None: return code if self.format not in ("css", "js", "html", "xhtml"): self.format = slimmer.guessSyntax(code) if self.format == "css": return slimmer.css_slimmer(code) elif self.format in ("js", "javascript"): return slimmer.js_slimmer(code) elif self.format == "xhtml": return slimmer.xhtml_slimmer(code) elif self.format == "html": return slimmer.html_slimmer(code) else: raise TemplateSyntaxError("Unrecognized format for slimming content") return code