Crates.io | wxml_parser |
lib.rs | wxml_parser |
version | 0.1.0 |
source | src |
created_at | 2022-02-23 12:26:00.293882 |
updated_at | 2022-02-23 12:26:00.293882 |
description | wxml parser |
homepage | https://crates.io/crates/wxml |
repository | https://github.com/yisar/wxml |
max_upload_size | |
id | 537828 |
size | 129,249 |
wean-wxml rust version, compile wxml source to fre jsx code.
pub mod lexer;
pub mod parser;
pub mod generator;
fn main() {
let mut parser = parser::Parser::new("<view wx:for=\"{{list}}\">
hello {{item}}!
<text wx:if=\"{{a}}\">a</text>
<text wx:elseif=\"{{b}}\">b</text>
<text wx:else />
</view>");
let ast = parser.parse_all().unwrap();
let mut gen = generator::Generator::new(ast);
let code = gen.generate_fre();
println!("{:#?}", code)
// <>{list.map((item)=><View>hello {item}!{a?<Text>a</Text>:b?<Text>b</Text>:ture?<Text/>:null}</View>)}</>
}