```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, Box::new(IncludeLocal::new("./include/")), None);
let updatexml = br#"
let r=wd.run(br#"
let updatexml = br#"
//update data.
/wd.run(r#"
let updatexml = br#"
//select data.
let r=wd.run(br#"
//seaech data
let r=wd.run(br#"
//use javascript let r=wd.run(br#"
const ymd=function(){
const now=new Date();
return now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate();
};
wd.general.uk="UK";
wd.general.ymd=function(){
const now=new Date();
return now.getFullYear()+"-"+(now.getMonth()+1)+"-"+now.getDate();
};
wd.general.result_options['test']="OK";
let hoge=wd.get_contents('body.xml');
console.log("hoge",hoge);
?>
<wd:search name="p" collection="person">
<field name="country" method="match" value:js="wd.general.uk" />
</wd:search>
<wd:result var="p" search="p">
<div>
<wd:print value:js="wd.general.ymd()" />
</div>
<div>
find <wd:print value:var="p.len" /> persons from the <wd:print value:js="wd.general.uk" />.
</div>
<ul>
<wd:for var="person" in:var="p.rows"><wd:record var="person" collection="person" row:var="person.row"><li>
<wd:print value:var="person.row" /> : <wd:print value:var="person.field.name" /> : <wd:print value:var="person.field.country" />
</li></wd:record></wd:for>
</ul>
</wd:result>
"#,b"").unwrap(); println!( "{} : {:#?}", std::str::from_utf8(r.body()).unwrap(), r.options() );
//search in update section.
let r=wd.run(br#"
//use WebAPI let r = wd .run( br#"
wd.general.result_options={};
wd.general.a="OK";
console.log(crypto.randomUUID());
wd.general.result_options.test="TEST";
wd.general.result_options.test2=crypto.randomUUID();
?>
a:<wd:print value:js="wd.general.a" />
input:<wd:print value:js="wd.v('input').name" />
<?js
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" />
"#, br#"{ "name":"Ken" ,"from":"US" }"#, ) .unwrap(); println!( "{} : {:#?}", std::str::from_utf8(r.body()).unwrap(), r.options() ); ```
xml
<html>
<head>
<title>HTML include test</title>
</head>
<body>
<wd:include src:var="body_path" />
</body>
</html>
xml
BODY
rust
let r=wd.run(br#"<wd:local body_path="body.xml">
<wd:include src="layout.xml" />
<wd:local>"#,b"");
println!("{}",r);
html
<html>
<head>
<title>HTML include test</title>
</head>
<body>
BODY
</body>
</html>
Specify features in Cargo.toml.
toml
wild-doc = { version = "x" , path = "../wild-doc" ,features=[ "js","py" ] }
rust
//use WebAPI
let r=wd.run(br#"<?py
hoge=100
def get_200():
return 200
?><wd:print value:py="get_200()" />"#,b"").unwrap();