Esempio n. 1
0
 def testStringAttr(self):
     self.assertEqual(
         '<div title="hello"></div>',
         hbml.compile(
             '%div(title="hello")'
         )
     )
Esempio n. 2
0
 def testExprAttrWithBrace(self):
     self.assertEqual(
         '<div data-id="HELLO"></div>',
         hbml.compile(
             '%div(data-id="hello".upper())'
         )
     )
Esempio n. 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))
Esempio n. 4
0
 def testSimpleAttr(self):
     self.assertEqual(
         '''<div id="yoyo" class="hello goodbye"></div>''',
         hbml.compile(
             "%div#yoyo.hello.goodbye"
         )
     )
Esempio n. 5
0
 def testExprAttrWithMultiBraces(self):
     self.assertEqual(
         '<div data-id="45"></div>',
         hbml.compile(
             '%div(data-id= 3 * ( 1 + 2 * ( 3 + 4)))'
         )
     )
Esempio n. 6
0
 def testExprAttr(self):
     self.assertEqual(
         '<div data-id="2"></div>',
         hbml.compile(
             '%div(data-id= 1 + 1)'
         )
     )
Esempio n. 7
0
 def testMultiStringAttr(self):
     self.assertEqual(
         '<div title="hello" alt="yoyo"></div>',
         hbml.compile(
             '%div(title="hello", alt="yoyo")'
         )
     )
Esempio n. 8
0
 def testSimpleSource(self):
     self.assertEqual(
         '''<div><h1></h1></div>''',
         hbml.compile((
             "%div\n"
             "  %h1"
         ))
     )
Esempio n. 9
0
 def testSimpleText(self):
     self.assertEqual(
         '<div><h2>hello</h2></div>',
         hbml.compile((
             "%div\n"
             "  %h2 hello"
         ))
     )
Esempio n. 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"
         ))
     )
Esempio n. 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)")'
         ))
     )
Esempio n. 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
            )
        )
Esempio n. 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"
             )
         )
     )
Esempio n. 14
0
 def testStringEscape(self):
     self.assertEqual(r'<a onclick="alert(\"hello\")">yoyo</a>',
                      hbml.compile(r'%a(onclick="alert(\"hello\")") yoyo'))
Esempio n. 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")
Esempio n. 16
0
 def testStringEscapeAtLast(self):
     self.assertEqual(r'<div title="h\""></div>',
                      hbml.compile(r'%div(title="h\"")'))
Esempio n. 17
0
 def testMultiAttrStringEscape(self):
     self.assertEqual(
         r'<a onclick="alert(\"hello\")" href="#">yoyo</a>',
         hbml.compile(r'%a(onclick="alert(\"hello\")", href="#") yoyo'))