webelements

Crates.iowebelements
lib.rswebelements
version0.1.1
sourcesrc
created_at2021-04-28 21:38:50.360697
updated_at2021-06-29 22:31:06.252558
descriptionA macro that transforms html to rust code
homepagehttps://github.com/pdragt/webelements
repositoryhttps://github.com/pdragt/webelements
max_upload_size
id390779
size14,892
Pepijn Dragt (pepijnd)

documentation

https://docs.rs/webelements

README

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)
}
Commit count: 0

cargo fmt