def do_test(filename): jade_file = cases.child(filename+".jade") jade_src = jade_file.text() html_file = cases.child(filename+".html") html_src = html_file.text().strip() result = jade.to_html(jade_src, tidy=True, context=context) assert html_src == result
def test_doctype(): data = """ !!! html body div """.strip() expected = [ 'document', ['doctype', "!!!"], ['element', ['open_tag', 'html'], ['nested_elements', ['element', ['open_tag', 'body'], ['nested_elements', ['element', ['open_tag', 'div']]]]]]] result = jade.generate_data(data) assert expected == result expected = ''' <!DOCTYPE html> <html> <body> <div></div> </body> </html>'''.strip() result = jade.to_html(data, tidy=True) assert expected == result
def test_doctype(): data = """ !!! html body div """.strip() expected = [ 'document', ['doctype', "!!!"], [ 'element', ['open_tag', 'html'], [ 'nested_elements', [ 'element', ['open_tag', 'body'], ['nested_elements', ['element', ['open_tag', 'div']]] ] ] ] ] result = jade.generate_data(data) assert expected == result expected = ''' <!DOCTYPE html> <html> <body> <div></div> </body> </html>'''.strip() result = jade.to_html(data, tidy=True) assert expected == result
def do_test(filename): jade_file = cases.child(filename + ".jade") jade_src = jade_file.text() html_file = cases.child(filename + ".html") html_src = html_file.text().strip() result = jade.to_html(jade_src, tidy=True, context=context) assert html_src == result
def do_test(data): expected = ['element', ['open_tag', data]] result = jade.generate_data(data, pattern=jade.element) assert expected == result expected = "<%(data)s></%(data)s>\n" % dict(data=data) result = jade.to_html(data) assert expected == result
def render(self, template_name, context=None): local_context = dict(self.globals) if context: local_context.update(context) f = self.directory.child("%s.jade" % template_name) text = f.text() html = jade.to_html(text, context=local_context) return html
def do_test(data): tag, content = [item.strip() for item in data.split("|")] expected = ['element', ['open_tag', tag, ['content', content]]] result = jade.generate_data(data, pattern=jade.element) assert expected == result expected = """<%(tag)s>%(content)s</%(tag)s>\n""" % dict( tag=tag, content=content) result = jade.to_html(data) assert expected == result
def do_test(data): tag, tag_class = data.split(".") expected = ['element', ['open_tag', tag, ['tag_class', tag_class]]] result = jade.generate_data(data, pattern=jade.element) assert expected == result expected = """<%(tag)s class="%(tag_class)s"></%(tag)s>\n""" % dict( tag=tag, tag_class=tag_class) result = jade.to_html(data) assert expected == result
def render(self, template_name, context=None): local_context = dict(self.globals) if context: local_context.update(context) f = self.directory.child("%s.jade" % template_name) if not f.exists(): raise TemplateNotFound() text = f.text() html = jade.to_html(text, context=local_context) return html
def do_test(data): tag, tag_class = data.split(".") expected = [ 'element', ['open_tag', tag, ['tag_class', tag_class]]] result = jade.generate_data(data, pattern=jade.element) assert expected == result expected = """<%(tag)s class="%(tag_class)s"></%(tag)s>\n""" % dict(tag=tag, tag_class=tag_class) result = jade.to_html(data) assert expected == result
def do_test(data): tag, content = [item.strip() for item in data.split("|")] expected = [ 'element', ['open_tag', tag, ['content', content]]] result = jade.generate_data(data, pattern=jade.element) assert expected == result expected = """<%(tag)s>%(content)s</%(tag)s>\n""" % dict(tag=tag, content=content) result = jade.to_html(data) assert expected == result
def test_text_filter(): src = """ extends anything append main div | foo1 | foo2 p | foo3 p | foo4 replace footer | foo_ter div """.strip() expected = """ <html> <head> <title>master_faa</title> </head> <body> <div> faa1faa2 <p> faa3 </p> <p></p> faa4 </div> <div> faa_ter <div></div> </div> </body> </html> """.strip() context = dict( loader=loader, _text_filter=_text_filter) data = jade.generate_data(src) result = jade.to_html(src, tidy=True, context=context) assert expected == result
def test_nested(): data = """ div#foo.bar p | A paragraph """.strip() expected = [ 'element', ['open_tag', "div", ['tag_id', "foo"], ['tag_class', "bar"]], [ 'nested_elements', ['element', ['open_tag', "p", ['content', "A paragraph"]]] ] ] result = jade.generate_data(data, pattern=jade.element) assert expected == result expected = '''<div id="foo" class="bar"><p>A paragraph</p></div>\n''' result = jade.to_html(data) assert expected == result
def test_text_filter(): src = """ extends anything append main div | foo1 | foo2 p | foo3 p | foo4 replace footer | foo_ter div """.strip() expected = """ <html> <head> <title>master_faa</title> </head> <body> <div> faa1faa2 <p> faa3 </p> <p></p> faa4 </div> <div> faa_ter <div></div> </div> </body> </html> """.strip() context = dict(loader=loader, _text_filter=_text_filter) data = jade.generate_data(src) result = jade.to_html(src, tidy=True, context=context) assert expected == result
def test_nested(): data = """ div#foo.bar p | A paragraph """.strip() expected = [ 'element', ['open_tag', "div", ['tag_id', "foo"], ['tag_class', "bar"]], ['nested_elements', ['element', ['open_tag', "p", ['content', "A paragraph"]]]]] result = jade.generate_data(data, pattern=jade.element) assert expected == result expected = '''<div id="foo" class="bar"><p>A paragraph</p></div>\n''' result = jade.to_html(data) assert expected == result