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.exec(r#" Noah US Liam US Olivia UK "#,b"").unwrap();/

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

//select data. let r=wd.exec(r#"

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

//seaech data let r=wd.exec(r#"

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

//use javascript let r=wd.exec(r#" const ymd=function(){ const now=new Date(); return now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate(); }; const uk="UK";

    wd.result_options['test']="OK";
</wd:script>
<wd:search name="p" collection="person">
    <field name="country" method="match" wd:value="uk" />
</wd:search>
<wd:result var="q" search="p">
    <div>
        <wd:print wd:value="ymd()" />
    </div>
    <div>
        find <wd:print wd:value="wd.v('q').length" /> persons from the <wd:print wd:value="uk" />.
    </div>
    <ul>
        <wd:for var="r" index="i" wd:in="wd.v('q')"><li>
            <wd:print wd:value="wd.v('r').row" /> : <wd:print wd:value="wd.v('r').field('name')" /> : <wd:print wd:value="wd.v('r').field('country')" />
        </li></wd:for>
    </ul>
</wd:result>

"#,"").unwrap(); println!("{} : {}",std::str::fromutf8(r.body()).unwrap(),r.optionsjson());

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

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

Include file

layout.xml

xml <html> <head> <title>HTML include test</title> </head> <body> <wd:include wd:src="wd.v('body_path')" /> </body> </html>

body.xml

xml BODY

rust

rust let r=wd.exec(r#"<wd><wd:stack var="body_path:'body.xml'"> <wd:include src="layout.xml" /> <wd:stack></wd>"#); println!("{}",r);

output

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