#web

webelements

A macro that transforms html to rust code

2 releases

0.1.1 Jun 29, 2021
0.1.0 Apr 28, 2021

#121 in GUI

MIT/Apache

31KB
734 lines

A macro that transforms html to rust code

use wasm_bindgen_test::{wasm_bindgen_test, wasm_bindgen_test_configure};
wasm_bindgen_test_configure!(run_in_browser);

use webelements::{we_builder, WebElement, WebElementBuilder};

#[we_builder(
    <div class="my-element" attr="value">
        <div class="repeated" we_field="repeated" we_repeat=5 />
    </div>
)]
#[derive(Debug, Clone, WebElement)]
struct MyElement {}

#[we_builder(
    <div class="my-element" attr="value">
        <MyElement we_field="elem" we_repeat=2 we_element />
    </div>
)]
#[derive(Debug, Clone, WebElement)]
struct OtherElement {}


#[wasm_bindgen_test]
fn test_we_elements() {
    let el = OtherElement::build().unwrap();
    assert_eq!(el.elem.first().unwrap().repeated.len(), 5)
}

Dependencies

~11MB
~219K SLoC