unchained

所属分类:其他
开发工具:Rust
文件大小:0KB
下载次数:0
上传日期:2024-03-29 10:20:30
上 传 者sh-1993
说明:  简单模板渲染器和路由器
(Simple template renderer and router)

文件列表:
eportfolio/
unchained/
Cargo.lock
Cargo.toml

# Unchained *Template renderer and router* > Created during the evenings of easter holiday ### Examples ```rust fn main() { let mut context = HashMap::new(); context.insert("page_links".to_string(), ctx_vec(vec![ ctx_map([("href", ctx_str("/#about")), ("label", ctx_str("About me"))]), ctx_map([("href", ctx_str("/experience")), ("label", ctx_str("Experience"))]), ctx_map([("href", ctx_str("/skills")), ("label", ctx_str("Skills"))]), ])); let template = template("templates/landing-page.html", Some(context)); let routes = vec![ Route::new(GET, String::from("/"), ResponseContent::Create(Box::new(move |_req| { return match &template { Ok(template) => Response::new_200(template.to_string()), Err(_e) => panic!("Could not render template"), }; }))), Route::new(GET, String::from("/images/*"), ResponseContent::None) ]; start_server(routes, ServerOptions {address: None}); } ``` ```html {* component templates/base.html {
{* for button in page_links { {* component templates/front-button.html label=button.label link=button.href *} } *}

About me

{* for image in images { {* image.alt *} } *}
} *} ```

近期下载者

相关文件


收藏者