本文整理汇总了Python中pyhaml.haml.to_html函数的典型用法代码示例。如果您正苦于以下问题:Python to_html函数的具体用法?Python to_html怎么用?Python to_html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了to_html函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testfunc
def testfunc(self):
haml = "-def foo():\n %p{'a':'b'}\n-for i in range(2):\n -foo()"
html = '<p a="b"></p>\n<p a="b"></p>\n'
self.assertEqual(html, to_html(haml))
haml = "-def foo():\n %a\n%p\n - foo()"
html = '<p>\n <a></a>\n</p>\n'
self.assertEqual(html, to_html(haml))
示例2: testfilters
def testfilters(self):
self.assertEqual('\n', to_html(':plain'))
self.assertEqual('foo\n bar\nbaz\n', to_html(':plain\n foo\n bar\n baz'))
self.assertEqual('<div></div>\n', to_html(':plain\n%div'))
self.assertRaises(Exception, partial(to_html, ':foo\n foo'))
self.assertEqual(
"<script type='text/javascript'>\n //<![CDATA[\n var foo;\n //]]>\n</script>\n",
to_html(':javascript\n\tvar foo;', format='xhtml'))
self.assertEqual(
"<script type='text/javascript'>\n var foo;\n</script>\n",
to_html(':javascript\n\tvar foo;'))
示例3: testtag
def testtag(self):
self.assertEqual('<div></div>\n', to_html("%div"))
self.assertEqual("<div id='id'></div>\n", to_html("#id"))
self.assertEqual("<div class='class'></div>\n", to_html(".class"))
self.assertEqual("<div class='foo bar'></div>\n", to_html(".foo.bar"))
self.assertEqual("<div id='foo' class='bar'></div>\n", to_html("#foo.bar"))
self.assertEqual("<img id='foo' class='bar baz'>\n", to_html("%img#foo.bar.baz"))
self.assertEqual("<p id='foo_bar'></p>\n", to_html("%p#foo{'id':'bar'}"))
self.assertEqual("<p id='foo'></p>\n", to_html("%p#foo{'id':None}"))
self.assertEqual("<p class='foo bar'></p>\n", to_html("%p.foo{'class':'bar'}"))
示例4: testautoclose
def testautoclose(self):
self.assertEqual('<sandwich/>\n', to_html('%sandwich/', format='xhtml'))
self.assertEqual("<script src='foo'></script>\n", to_html("%script{'src':'foo'}"))
self.assertEqual("<script src='foo'>fallback</script>\n", to_html("%script{'src':'foo'} fallback"))
self.assertEqual("<script src='foo'>\n bar\n</script>\n", to_html("%script{'src':'foo'}\n bar"))
self.assertEqual("<link rel='stylesheet'>\n", to_html("%link{'rel':'stylesheet'}"))
self.assertEqual("<link rel='stylesheet'>foo</link>\n", to_html("%link{'rel':'stylesheet'} foo"))
self.assertEqual("<meta content='text/html'>\n", to_html("%meta{'content':'text/html'}"))
self.assertEqual("<input type='text'/>\n", to_html("%input{ 'type':'text' }", format='xhtml'))
self.assertEqual("<foo>\n<bar>\n", to_html("%foo\n%bar", autoclose=['foo','bar']))
示例5: testtrim
def testtrim(self):
self.assertEqual('<img><img><img>\n', to_html('%img\n%img>\n%img'))
self.assertEqual('<p><b>foo</b></p>\n', to_html('%p\n %b<>\n foo'))
self.assertEqual("<p><b a='b'>foo</b></p>\n", to_html("%p\n %b{'a':'b'}<>\n foo"))
self.assertEqual("<p><b>\n a\n</b></p>\n", to_html("%p\n %b>\n a"))
self.assertEqual("<p>\n <b>a</b>\n</p>\n", to_html("%p\n %b<\n a"))
self.assertEqual("<p><b></b></p>\n", to_html('-def f():\n %b>\n%p\n -f()'))
self.assertEqual("<p><b></b></p>\n", to_html('-def f():\n %b\n%p<\n -f()'))
self.assertEqual("<p><p>\n foo\n</p></p>\n", to_html('%p\n %p>\n foo'))
示例6: testtag
def testtag(self):
self.assertEqual('<div></div>\n', to_html("%div"))
self.assertEqual('<div id="id"></div>\n', to_html("#id"))
self.assertEqual('<div class="class"></div>\n', to_html(".class"))
self.assertEqual('<div class="foo bar"></div>\n', to_html(".foo.bar"))
self.assertEqual('<div id="foo" class="bar"></div>\n', to_html("#foo.bar"))
self.assertEqual('<img id="foo" class="bar baz"/>\n', to_html("%img#foo.bar.baz"))
示例7: testsilent
def testsilent(self):
self.assertEqual('\n', to_html('-#'))
self.assertEqual('<p></p>\n<p></p>\n', to_html("%p\n-# foo\n%p"))
self.assertEqual('<p></p>\n<p></p>\n', to_html("%p\n-# foo\n bar\n baz\n%p"))
self.assertEqual('<div>\n <span>foo</span>\n</div>\n', to_html("%div\n %span foo\n -# foo\n bar\n baz"))
self.assertEqual('<div>\n <p>\n <b></b>\n </p>\n</div>\n', to_html('%div\n %p\n -#foo\n %b'))
self.assertEqual('<p></p>\n', to_html('%p\n -#\n \n %b'))
示例8: testattrs
def testattrs(self):
self.assertEqual("<p a='b'></p>\n", to_html("%p{ 'a':'b', 'c':None }"))
self.assertEqual("<div style='ugly' class='atlantis'></div>\n", to_html(".atlantis{'style' : 'ugly'}"))
self.assertEqual("<img alt=''>\n", to_html("%img{'alt':''}"))
self.assertEqual("<p foo='bar}'></p>\n", to_html("%p{'foo':'bar}'}"))
self.assertEqual("<p foo='{bar'></p>\n", to_html("%p{'foo':'{bar'}"))
self.assertEqual("<p foo='bar'></p>\n", to_html("%p{'foo':'''bar'''}"))
示例9: testmultiline
def testmultiline(self):
self.assertEqual('<p>multi line string</p>\n', to_html('%p multi |\n line |\n string |'))
self.assertEqual('<p>multi %line .string</p>\n<p></p>\n', to_html('%p multi |\n %line |\n .string |\n%p'))
self.assertEqual('<p>\n multi %line .string\n</p>\n', to_html('%p\n multi |\n %line |\n .string |'))
self.assertEqual('multi %line .string\n', to_html('multi |\n%line |\n.string |'))
self.assertEqual('<p>multi line</p>\n', to_html('%p multi |\n \n line |\n'))
self.assertEqual('<p>\n multi line\n</p>\n<p></p>\n', to_html('%p\n multi |\n line |\n%p'))
示例10: testoneline
def testoneline(self):
self.assertEqual('<p>foo</p>\n', to_html('%p foo'))
示例11: testdictlocals
def testdictlocals(self):
def foo():
return 'bar'
self.assertEqual("<p foo='bar'></p>\n", to_html("%p{'foo':foo}", {'foo':'bar'}))
self.assertEqual("<p foo='bar'></p>\n", to_html("%p{'foo':foo()}", {'foo':foo}))
示例12: testempty
def testempty(self):
self.assertEqual('', to_html(''))
示例13: testattrwithscript
def testattrwithscript(self):
self.assertEqual("<p foo='bar'></p>\n", to_html("-foo='bar'\n%p{'foo':foo}"))
示例14: testbackslashstart
def testbackslashstart(self):
self.assertEqual('#\n', to_html('\\#'))
self.assertEqual('.foo\n%bar\n', to_html('\\.foo\n\\%bar'))
self.assertEqual('<div>foo</div>\n', to_html('%div \\foo'))
self.assertEqual('<p>.foo</p>\n<p>%bar</p>\n', to_html('%p\\.foo\n%p\\%bar'))
示例15: testmulti
def testmulti(self):
self.assertEqual('<strong>foo</strong>\n', to_html('%strong foo'))
self.assertEqual('<strong>foo</strong>\n', to_html('%strong foo'))
self.assertEqual('<strong>foo</strong>\n', to_html('%strong foo'))