syn-rsx

crates.io page docs.rs page build license: MIT

syn-powered parser for JSX-like TokenStreams. The parsed result is a nested Node structure, similar to the browser DOM.

```rust use quote::quote; use syn::Expr; use syn_rsx::parse2;

let tokens = quote! {

"hello"
}; let nodes = parse2(tokens, None).unwrap();

let node = &nodes[0]; asserteq!(node.attributes[0].nameasstring().unwrap(), "foo"); assert!({ if let Some(Expr::Block()) = node.attributes[0].value { true } else { false } });

let childs = &node.childs; asserteq!(childs.len(), 2); asserteq!(childs[0].childs[0].valueasstring().unwrap(), "hello"); asserteq!(childs[1].nameas_string().unwrap(), "world"); ```