/cig

JSX like syntax parser in Rust

Primary LanguageRustApache License 2.0Apache-2.0

JSX parser in Rust

Simple and light JSX like syntax parser, written in Rust, building this as macro coding experiment.

Spews out Node struct with children and attributes attached.

  • Examples
use cig::{rsx, Node};

let node: Node = rsx!(<test data={"entry"}></test>);

let node: Node = rsx!(<test data={"entry"}>
                        {
                            ["test", "test2"]
                            .iter()
                            .map(|x| {
                                rsx!(<node>
                                        <children data={x}/>
                                        <image/>
                                        <text/>
                                    </node>)
                            })
                            .collect::<Vec<Node>>()
                        }
                        </test>);
                        
                        
                        
let click = || println!("{:?}", "data");                        
let node = rsx!(<test onClick={ click } onHover={click} data1={"test"} data2={"test2"}></test>);