[−][src]Crate syn_rsx
syn
-powered parser for JSX-like TokenStream
s. The parsed result is a
nested Node
structure, similar to the browser DOM.
use quote::quote; use syn_rsx::parse2; let tokens = quote! { <div foo={bar}> <div>"hello"</div> <world /> </div> }; let nodes = parse2(tokens, None).unwrap(); let node = &nodes[0]; assert_eq!(node.attributes[0].name_as_string().unwrap(), "foo"); let children = &node.children; assert_eq!(children.len(), 2); assert_eq!(children[0].children[0].value_as_string().unwrap(), "hello"); assert_eq!(children[1].name_as_string().unwrap(), "world");
Structs
Node | Node in the tree |
Parser | RSX Parser |
ParserConfig | Configures the |
Enums
NodeType | Type of the Node |
Functions
parse | Parse the given |
parse2 | Parse the given |