Example #1
0
def test_fragment_get_slice():
    hl = Tag("html")
    hd = Tag("head")
    m = SelfClosingTag("meta", SelfClosingTagStyle.HTML)
    b = Tag("body")
    p = Tag("p")

    f = +hl + hd + m - hd + b + p + "The Paragraph"
    assert str(f[3:5]) == "<p>The Paragraph"
Example #2
0
def my_tag_with_id_and_classes(my_tag):
    return Tag("my-tag", id_="title", class_=["heading", "uppercase"])
Example #3
0
def my_tag_with_attributes(my_tag):
    return Tag("my-tag", attr1="val1", attr2="val2")
Example #4
0
def my_tag():
    return Tag("my-tag")
Example #5
0
def test_fragment_minus_tag():
    f = Fragment()
    html = Tag("html")
    assert str(f - html) == "</html>"
Example #6
0
def test_self_closing_tag_inside_balanced_tags():
    head = Tag("head")
    meta = SelfClosingTag("meta", SelfClosingTagStyle.HTML)
    f = Fragment()
    assert str(f + head + meta - head) == "<head><meta></head>"
Example #7
0
def test_fragment_plus_untyped_tag():
    t = Tag("html")
    f = Fragment()
    assert str(f + t) == "<html>"
Example #8
0
def h1():
    return Tag("h1")