Пример #1
0
 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')
Пример #2
0
 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')
Пример #3
0
 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
Пример #4
0
 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
Пример #5
0
 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
Пример #6
0
    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
Пример #7
0
 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
Пример #8
0
    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
Пример #9
0
    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
Пример #10
0
    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