2.7 KiB
2.7 KiB
✨ Features
- Simple and intuitive syntax inspired by EJS
- Relatively small number of dependencies (<15 crates in total)
- Extremely fast (See benchmarks)
- Better error message
- Template rendering is always type-safe because templates are statically compiled.
- Syntax highlighting support (vscode, vim)
- Automatically re-compile sources when template file is updated.
⚠️ Currentry sailfish is in early-stage development. You can use this library but be sure that there might be some bugs. Also API is still unstable, and thus may changes frequently.
🐟 Example
Dependencies:
[dependencies]
sailfish = "0.0.1"
sailfish-macros = "0.0.1"
Template file (templates/hello.stpl):
<DOCTYPE! html>
<html>
<body>
<%= content %>
</body>
</html>
Code:
#[macro_use]
extern crate sailfish_macros; // enable derive macro
use sailfish::TemplateOnce;
#[derive(TemplateOnce)]
#[template(path = "hello.stpl")]
struct Hello {
content: String
}
fn main() {
println!("{}", Hello { content: String::from("Hello, world!") }.render_once().unwrap());
}
You can find more examples in examples directory.
🐾 Roadmap
Template
trait (RFC)- Template inheritance (block, partials, etc.)
- Include another templates without copy
- Whitespace suppressing
- HTML minification
- Filters
- Dynamic template compilation (RFC)
format_templates!(fmt, args..)
macro
👤 Author
🇯🇵 Ryohei Machida
- Github: @Kogia-sima
🤝 Contributing
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Show your support
Give a ⭐️ if this project helped you!
📝 License
Copyright © 2020 Ryohei Machida.
This project is MIT licensed.
This README was generated with ❤️ by readme-md-generator