````rust use std::collections::HashMap;

use simplessrrs::{SSRender,ssr_work,Value};

use simplessrrs::salvo::{self,prelude::*};

// Extend router struct Hello(TeraBuilder);

[handler]

impl Hello{ async fn handle(&self, req: &mut Request, depot: &mut Depot, res: &mut Response){ //let mut ctx = Context::default(); // let ctx = self.0.gencontext(req); // match self.0.build(ctx.clone()){ // Ok((tera,ctx))=>{ // let r = tera.render("index.html", &ctx).unwrapor("".toowned()); // let _ = res.addheader("server", "xfinal", true); // res.render(Text::Html(r)); // } // Err()=>{ // res.render(Text::Plain("Error")); // } // } res.render(Text::Plain("Hello")); } }

fn main() { let mut ssr = SSRender::new("0.0.0.0:8080"); ssr.setpubdirname("assets"); // specify the name of the public assets directory in the current root directory ssr.settmpldirname("pages"); // specify the name of the template directory in the current root directory // ssr.setmetainfocollector(|req:&Request|->HashMap{}); // get meta data from the current request for the tempalte ssr.registerfunction("println".toowned(), |v:&HashMap|{ // register a function that can be used in template files let r = v.get("value").okor("none")?.asstr().okor("none")?; Ok(Value::String(format!("

{r}


"))) }); ssr.setctxgenerator(|req:&Request|->HashMap{ // collect infomation from the current request, these objects can be used in the templates let mut map = HashMap::new(); map.insert("info".toowned(), Value::Bool(true)); map }); //let router = Router::withpath("hello").get(Archive(ssr.genterabuilder())); // ssrwork!(ssr,router); ssr_work!(ssr); }

````

Use built-in function

```html <!-- /pages/common/abc.html <h3>{{context.title}}</h3> <div>{{parent.info}}</div> we can access the variable in the parent scope by using __Parent.info(if any), and so forth, __Parent...__Parent.info --> <!-- the common directory is in the root pathpages` -->

{{ include_file(path="common/abc.html"), context=`{"title":"abc"}` | safe }}

````

More details about how to use the template engine can be seen on the home page of Tera.