def test_renders(): @renders(e.p()("{x}"), e.p()("{x} again")) def render_paras(data: dict) -> dict: return {"x": data["x"]} assert render_paras({"x": "y"}) == b"<p>y</p><p>y again</p>" dangerous_script = "<script>I'm dangerous</script>" assert render_paras({"x": dangerous_script}) == raw( f"<p>{escape(dangerous_script)}</p><p>{escape(dangerous_script)} again</p>" ) assert render_paras({"x": raw(dangerous_script)}) == raw( f"<p>{dangerous_script}</p><p>{dangerous_script} again</p>" ) @renders(e.li()("{item}")) def render_list_item(item): return {"item": item} @renders(e.p()("{foo}"), e.ul()("{list_items}")) def render_component(): return { "foo": e.hr, "list_items": fn.foreach(["a", "b", "c"])(lambda x: render_list_item(x)), } assert ( render(render_component()) == "<p><hr /></p><ul><li>a</li><li>b</li><li>c</li></ul>" )
def test_render(): assert render(" ") == "&nbsp;" assert render(txt(" ")) == "&nbsp;" assert render(b" ") == " " assert render(raw(" ")) == " " assert render(e.p(), e.p()) == "<p></p><p></p>" with pytest.raises(ValueError): render(1)
def test_renders(): @renders(e.p()("{x}"), e.p()("{x} again")) def render_paras(data: dict) -> dict: return {"x": data["x"]} assert render_paras({"x": "y"}) == "<p>y</p><p>y again</p>" render_paras = renders(e.p()("{x}"), e.p()("{x} again"))( lambda data: {"x": data["x"]} ) assert render_paras({"x": "y"}) == "<p>y</p><p>y again</p>"
def test_renders(): @renders(e.p()("{x}"), e.p()("{x} again")) def render_paras(data: dict) -> dict: return {"x": data["x"]} assert render_paras({"x": "y"}) == b"<p>y</p><p>y again</p>" dangerous_script = "<script>I'm dangerous</script>" assert render_paras({"x": dangerous_script}) == raw( f"<p>{escape(dangerous_script)}</p><p>{escape(dangerous_script)} again</p>" ) assert render_paras({ "x": raw(dangerous_script) }) == raw(f"<p>{dangerous_script}</p><p>{dangerous_script} again</p>")
def test_composite_tag(): assert render(composite_tag("p")()()) == "<p></p>" assert render(p()(txt("x"))) == "<p>x</p>" assert render(p(class_="y")(txt("x"))) == '<p class="y">x</p>' assert render(p("a")(txt("x"))) == "<p a>x</p>" assert render(p("a", b="c")(txt("x"))) == '<p a b="c">x</p>' assert render(p(b="c")(txt("x"))) == '<p b="c">x</p>' assert render(p(b="c")(p()(txt("x")))) == '<p b="c"><p>x</p></p>'
from htmldoom import elements as e from htmldoom import render, renders def badge(href: str, src: str, alt: str): return e.span()(e.a(href=href)(e.img(src=src, alt=alt))) def plugin(title: str, href: str, description: str): return e.ul()(e.li()(e.a(href=href)(e.b()(title)), e.span()(f": {description}"))) readme = ( e.h1(align="center")("htmldoom"), e.p(align="center")( "An intuitive, high performance HTML rendering framework"), e.p(align="center")( badge( href="https://pypi.org/project/htmldoom", src="https://img.shields.io/pypi/v/htmldoom.svg", alt="PyPI version", ), b" ", badge( href="https://pypi.org/project/htmldoom", src="https://img.shields.io/pypi/pyversions/htmldoom.svg", alt="PyPI version", ), b" ", badge( href="https://travis-ci.org/sayanarijit/htmldoom",
)("View Our Projects"), e.a( href="/team", class_= "btn btn-outline-primary btn-lg d-block d-sm-inline ml-sm-2 mt-3 mt-sm-2 text-white", )("Meet Our Team"), ))), ), b.comment(" END HOME "), b.comment(" VALUES "), e.section()(e.div(class_="container")( e.div(class_="row")(e.div(class_="col-md text-center")( e.h1()("Our Values"), e.p()( "These values are at the core of our company. ", e.br(), " ", e.a(href="/about")("Learn more about Niteo ..."), ), )), e.div(class_="row justify-content-between")( e.div(class_="col-2 d-none d-lg-block") (e.div(class_="row justify-content-center")(e.div( class_="col wow rotateInDownRight", data_wow_delay=".3s" )(e.img( src= "https://niteo.co/static_niteo_co/images/homepage/homepage_openness.svg", class_="img-fluid niteo-value mx-auto d-block", alt="openness", )))), e.div(class_="col-2 d-none d-lg-block") (e.div(class_="row justify-content-center")(e.div(
"""The README.md generator""" from htmldoom import elements as e from htmldoom import render def badge(href: str, src: str, alt: str): return e.span()(e.a(href=href)(e.img(src=src, alt=alt))) readme = ( e.h1(align="center")("htmldoom"), e.p(align="center")("An intuitive, high performance HTML rendering framework"), e.p(align="center")( badge( href="https://pypi.org/project/htmldoom", src="https://img.shields.io/pypi/v/htmldoom.svg", alt="PyPI version", ), b" ", badge( href="https://pypi.org/project/htmldoom", src="https://img.shields.io/pypi/pyversions/htmldoom.svg", alt="PyPI version", ), b" ", badge( href="https://travis-ci.org/sayanarijit/htmldoom", src="https://travis-ci.org/sayanarijit/htmldoom.svg?branch=master", alt="Build Status", ),