Beispiel #1
0
 def testStringAttr(self):
     self.assertEqual(
         '<div title="hello"></div>',
         hbml.compile(
             '%div(title="hello")'
         )
     )
Beispiel #2
0
 def testExprAttrWithBrace(self):
     self.assertEqual(
         '<div data-id="HELLO"></div>',
         hbml.compile(
             '%div(data-id="hello".upper())'
         )
     )
Beispiel #3
0
 def _test_uncompress_file(self, filename):
     self.assertEqual(
         _file_content(os.path.join(DIRPATH,
                                    filename + '.uncompress.html')),
         hbml.compile(_file_content(
             os.path.join(DIRPATH, filename + '.hbml')),
                      compress_output=False))
Beispiel #4
0
 def testSimpleAttr(self):
     self.assertEqual(
         '''<div id="yoyo" class="hello goodbye"></div>''',
         hbml.compile(
             "%div#yoyo.hello.goodbye"
         )
     )
Beispiel #5
0
 def testExprAttrWithMultiBraces(self):
     self.assertEqual(
         '<div data-id="45"></div>',
         hbml.compile(
             '%div(data-id= 3 * ( 1 + 2 * ( 3 + 4)))'
         )
     )
Beispiel #6
0
 def testExprAttr(self):
     self.assertEqual(
         '<div data-id="2"></div>',
         hbml.compile(
             '%div(data-id= 1 + 1)'
         )
     )
Beispiel #7
0
 def testMultiStringAttr(self):
     self.assertEqual(
         '<div title="hello" alt="yoyo"></div>',
         hbml.compile(
             '%div(title="hello", alt="yoyo")'
         )
     )
Beispiel #8
0
 def testSimpleSource(self):
     self.assertEqual(
         '''<div><h1></h1></div>''',
         hbml.compile((
             "%div\n"
             "  %h1"
         ))
     )
Beispiel #9
0
 def testSimpleText(self):
     self.assertEqual(
         '<div><h2>hello</h2></div>',
         hbml.compile((
             "%div\n"
             "  %h2 hello"
         ))
     )
Beispiel #10
0
 def testNoTerminateTag(self):
     self.assertEqual(
         '<div data-id="2" data-name="hello"><h2></h2></div>',
         hbml.compile((
             "%div(data-id= 1 + 1,\n"
             "     data-name=\"hello\")\n"
             "  %h2"
         ))
     )
Beispiel #11
0
 def testInBracketAttr(self):
     self.assertEqual(
         (
             '<div title="hello" data-id="2"'
             ' onclick="a = 1, b = 2, c = 3; item_clicked(a, b)"></div>'
         ),
         hbml.compile((
             '%div(title="hello", data-id="2",'
             ' onclick="a = 1, b = 2, c = 3; item_clicked(a, b)")'
         ))
     )
Beispiel #12
0
    def testDontCompress(self):
        self.assertEqual(
            '''<div><h1></h1></div>''',
            hbml.compile((
                "%div\n"
                "  %h1"
            ))
        )

        self.assertEqual(
            '<div>\n'
            '  <h1></h1>\n'
            '</div>\n',
            hbml.compile(
                (
                    "%div\n"
                    "  %h1"
                ),
                compress_output=False
            )
        )
Beispiel #13
0
 def testVariables(self):
     self.assertEqual(
         '<div data-length="5">HELLO</div>',
         hbml.compile(
             (
                 "%div(data-length=len(content))\n"
                 "  = content.upper()"
             ),
             dict(
                 content="hello"
             )
         )
     )
Beispiel #14
0
 def testStringEscape(self):
     self.assertEqual(r'<a onclick="alert(\"hello\")">yoyo</a>',
                      hbml.compile(r'%a(onclick="alert(\"hello\")") yoyo'))
Beispiel #15
0
 def _test_file(self, filename):
     self.assertEqual(
         _file_content(os.path.join(DIRPATH, filename + '.html')),
         hbml.compile(
             _file_content(os.path.join(DIRPATH, filename + '.hbml'))) +
         "\n")
Beispiel #16
0
 def testStringEscapeAtLast(self):
     self.assertEqual(r'<div title="h\""></div>',
                      hbml.compile(r'%div(title="h\"")'))
Beispiel #17
0
 def testMultiAttrStringEscape(self):
     self.assertEqual(
         r'<a onclick="alert(\"hello\")" href="#">yoyo</a>',
         hbml.compile(r'%a(onclick="alert(\"hello\")", href="#") yoyo'))