wild-doc

Example

```rust use wild_doc::*;

let dir="./wd-test/"; if std::path::Path::new(dir).exists(){ std::fs::removedirall(dir).unwrap(); } std::fs::createdirall(dir).unwrap();

let mut wd=WildDoc::new( dir ,IncludeLocal::new("./include/") ).unwrap();

//update data. /wd.run(br#" Noah US Liam US Olivia UK "#,b"").unwrap();/

let updatexml=br#" "#; wd.run(updatexml,br#"{ "name":"Noah" ,"from":"US" }"#).unwrap(); wd.run(updatexml,br#"{ "name":"Liam" ,"from":"US" }"#).unwrap(); wd.run(updatexml,br#"{ "name":"Olivia" ,"from":"UK" }"#).unwrap();

//select data. let r=wd.run(br#"

find persons.
"#,b"").unwrap(); println!("{}",std::str::from_utf8(r.body()).unwrap());

//seaech data let r=wd.run(br#"

find persons from the US.
"#,b"").unwrap(); println!("{}",std::str::from_utf8(r.body()).unwrap());

//use javascript let r=wd.run(br#" options['test']="OK"; ?>

find persons from the .
"#,b"").unwrap(); println!("{} : {}",std::str::fromutf8(r.body()).unwrap(),r.options_json());

//search in update section. wd.run(br#" hoge: Renamed "#,b"").unwrap(); let r=wd.run(br#"

find persons.
"#,b"").unwrap(); println!("{}",std::str::from_utf8(r.body()).unwrap());

//use WebAPI let r=wd.run(br#"

    wd.general.a="OK";
    wd.stack.push({
        hoge:{
            hoge:"A"
        }
        ,a:1
    });
    console.log(crypto.randomUUID());
    wd.result_options.test="TEST";
    wd.result_options.test2=crypto.randomUUID();
?>
a:<wd:print value:js="wd.general.a" />
v:<wd:print value:var="a" />
input:<wd:print value:var="input.name" />
<?js
    wd.stack.pop();
    wd.general.a="OK2";
    wd.general.b=1>2;
?>
a:<wd:print value:js="wd.general.a" />
v:<wd:print value:js="wd.general.b" /><global var="result_options" value:js="wd.result_options" />

"#,br#"{ "name":"Ken" ,"from":"US" }"#).unwrap(); println!("{} : {}",std::str::fromutf8(r.body()).unwrap(),r.optionsjson()); ```

Include file

layout.xml

xml <html> <head> <title>HTML include test</title> </head> <body> <wd:include src:var="body_path" /> </body> </html>

body.xml

xml BODY

rust

rust let r=wd.run(br#"<wd:local body_path="body.xml"> <wd:include src="layout.xml" /> <wd:local>"#,b""); println!("{}",r);

output

html <html> <head> <title>HTML include test</title> </head> <body> BODY </body> </html>

Use python

Specify features in Cargo.toml. toml wild-doc = { version = "x" , path = "../wild-doc" ,features=[ "js","py" ] }

code

rust //use WebAPI let r=wd.run(br#"<?py hoge=100 def get_200(): return 200 ?><wd:print value:py="get_200()" />"#,b"").unwrap();