Introducing Pencil: A Microframework Inspired By Flask For Rust — Shipeng Feng’s Writings

Templating
Just create the templates folder under your application root path, it just works. You can customize the template folder.



Hello {{ name }}!



fn hello_template(request: &mut Request) -> PencilResult {
let mut context = BTreeMap::new();
context.insert(“name”.to_string(), “template”.to_string());
return request.app.render_template(“hello.html”, &context);
}

fn main() {
// app here