Пример #1
0
def test_loadyaml_static():
    my_alert = ly("tests/assets/yaml_components/red_alert.yml", static=True)
    your_alert = e.div()(
        e.span("boolattr", style="background-color: red",
               class_="alert")("This is an Alert"),
        e.i(class_="horror")("{{!}}"),
    )
    assert my_alert == your_alert
Пример #2
0
def test_invalid_format():
    for i in range(13):
        with pytest.raises(ValueError) as e:
            ly(YAML_INVALID_COMPONENTS, str(i))
        assert VALID_FORMAT in str(e.value)
Пример #3
0
def test_components_leaf_tag_with_multiple_tags():
    my_tag = render(ly(YAML_COMPONENTS, "composite_tag.with_multiple_tags"))
    your_tag = render(
        composite_tag("sometag")()("1"), "\n",
        composite_tag("sometag")()("2"))
    assert my_tag == your_tag
Пример #4
0
def test_components_composite_tag_vals():
    my_tag = ly(YAML_COMPONENTS, "composite_tag.with_nested_tag")
    your_tag = composite_tag("sometag")(class_="row")(e.i()("val"))
    assert my_tag == your_tag
Пример #5
0
def test_components_composite_tag_vals():
    my_tag = ly(YAML_COMPONENTS, "composite_tag.with_attrs_and_vals")
    your_tag = composite_tag("sometag")(class_="row")("val1", "val2")
    assert my_tag == your_tag
Пример #6
0
def test_components_composite_tag_with_attrs():
    my_tag = ly(YAML_COMPONENTS, "composite_tag.with_attrs")
    your_tag = composite_tag("sometag")(class_="row")()
    assert my_tag == your_tag
Пример #7
0
def test_components_composite_tag_empty():
    my_tag = ly(YAML_COMPONENTS, "composite_tag.empty")
    your_tag = composite_tag("sometag")()()
    assert my_tag == your_tag
Пример #8
0
def test_switch():
    assert ly(YAML_COMPONENTS, ("switch", "case", True)) == txt("true")
    assert ly(YAML_COMPONENTS, ("switch", "case", False)) == txt("false")
Пример #9
0
def test_somevalue():
    assert ly(YAML_COMPONENTS, "somevalue.foo") == txt("bar")
    assert ly(YAML_COMPONENTS, ("somevalue", "foo")) == txt("bar")
Пример #10
0
from htmldoom import doctype, renders
from htmldoom.yaml_loader import loadyaml as ly

LAYOUTS_DIR = "docs/src/layouts"


@renders(doctype("html"), ly(f"{LAYOUTS_DIR}/fullpage.yml", "default"))
def document(**values):
    """The document renderer."""
    return values