1 个不稳定版本
0.1.0 | 2024年1月10日 |
---|
#524 在 模板引擎
在 2 crate 中使用
15KB
357 行
Ibex
Ibex 使用过程宏在 Rust 中提供 SSG/SSR 的舒适 HTML 模板。
仍在开发中。
查看 Ibex Template 以快速入门。
示例
fn at_blog(blog: BlogPost) -> Document {
// Creates a `View` and converts to `Document`
view! {
// Calls a function `header(true)`
@header[true]
// Some html elements
h2 { [blog.title] }
h3 { i {[blog.author]} }
// Include any variables in scope
p {
[blog.body]
}
// Variables can be used in attributes
// Use a slash to signify an empty element body
img [src=blog.image]/
// Any syntax can be used with `if` or `for` statements (except `else-if`)
[:if let Some(image_src) = blog.image {
image [src=image_src]/
}]
}
.into()
}