2020-06-04 16:39:33 -04:00
< div align = "center" >
![SailFish ](./resources/logo.png )
Simple, small, and extremely fast template engine for Rust
2022-02-19 00:47:00 -05:00
[![Tests ](https://github.com/rust-sailfish/sailfish/workflows/Tests/badge.svg )](https://github.com/rust-sailfish/sailfish/actions?query=workflow%3ATests)
2020-06-05 10:42:06 -04:00
[![Version ](https://img.shields.io/crates/v/sailfish )](https://crates.io/crates/sailfish)
2022-02-19 00:47:00 -05:00
[![dependency status ](https://deps.rs/repo/github/rust-sailfish/sailfish/status.svg )](https://deps.rs/repo/github/rust-sailfish/sailfish)
2021-01-01 12:26:41 -05:00
[![Rust 1.42 ](https://img.shields.io/badge/rust-1.42+-lightgray.svg )](https://blog.rust-lang.org/2020/03/12/Rust-1.42.html)
2022-02-19 00:47:00 -05:00
[![License: MIT ](https://img.shields.io/badge/License-MIT-yellow.svg )](https://github.com/rust-sailfish/sailfish/blob/master/LICENSE)
2020-06-05 10:42:06 -04:00
2022-04-22 10:51:59 -04:00
[User Guide ](https://rust-sailfish.github.io/sailfish/ ) | [API Docs ](https://docs.rs/sailfish ) | [Examples ](./examples )
2020-06-09 08:48:39 -04:00
2020-06-04 16:39:33 -04:00
< / div >
## ✨ Features
- Simple and intuitive syntax inspired by [EJS ](https://ejs.co/ )
2021-01-03 08:58:22 -05:00
- Include another template file inside template
2021-01-01 04:21:39 -05:00
- Built-in filters
2021-01-03 08:58:22 -05:00
- Minimal dependencies (< 15 crates in total )
2020-12-15 23:38:17 -05:00
- Extremely fast (See [benchmarks ](https://github.com/djc/template-benchmarks-rs ))
2020-06-04 16:39:33 -04:00
- Better error message
- Syntax highlighting support ([vscode](./syntax/vscode), [vim ](./syntax/vim ))
2020-06-16 11:08:40 -04:00
- Works on Rust 1.42 or later
2020-06-04 16:39:33 -04:00
## 🐟 Example
Dependencies:
```toml
[dependencies]
2022-10-25 09:44:36 -04:00
sailfish = "0.5.0"
2020-06-04 16:39:33 -04:00
```
Template file (templates/hello.stpl):
2020-06-08 00:14:09 -04:00
```erb
2020-06-04 16:39:33 -04:00
< html >
< body >
2020-06-19 05:27:19 -04:00
< % for msg in & messages { %>
< div > < %= msg %>< / div >
< % } %>
2020-06-04 16:39:33 -04:00
< / body >
< / html >
```
Code:
```rust
use sailfish::TemplateOnce;
#[derive(TemplateOnce)]
#[template(path = "hello.stpl")]
2020-06-19 05:27:19 -04:00
struct HelloTemplate {
messages: Vec< String >
2020-06-04 16:39:33 -04:00
}
fn main() {
2020-06-19 05:27:19 -04:00
let ctx = HelloTemplate {
2020-12-24 01:53:35 -05:00
messages: vec![String::from("foo"), String::from("bar")],
};
2020-06-19 05:27:19 -04:00
println!("{}", ctx.render_once().unwrap());
2020-06-04 16:39:33 -04:00
}
```
You can find more examples in [examples ](./examples ) directory.
## 🐾 Roadmap
2022-02-19 00:47:00 -05:00
- `Template` trait ([RFC](https://github.com/rust-sailfish/sailfish/issues/3))
2020-06-04 16:39:33 -04:00
- Template inheritance (block, partials, etc.)
## 👤 Author
2020-07-02 05:28:22 -04:00
🇯🇵 **Ryohei Machida**
2020-06-04 16:39:33 -04:00
2021-01-01 04:21:39 -05:00
* GitHub: [@Kogia-sima ](https://github.com/Kogia-sima )
2020-06-04 16:39:33 -04:00
## 🤝 Contributing
Contributions, issues and feature requests are welcome!
2022-02-19 00:47:00 -05:00
Since sailfish is an immature library, there are many [planned features ](https://github.com/rust-sailfish/sailfish/labels/Type%3A%20RFC ) that is on a stage of RFC. Please leave a comment if you have an idea about its design!
2020-06-19 05:27:19 -04:00
2022-04-22 10:51:59 -04:00
Also I welcome any pull requests to improve sailfish! Find issues with [Status: PR Welcome ](https://github.com/rust-sailfish/sailfish/issues?q=is%3Aissue+is%3Aopen+label%3A%22Status%3A+PR+Welcome%22 ) label, and [let's create a new pull request ](https://github.com/rust-sailfish/sailfish/pulls )!
2020-06-04 16:39:33 -04:00
## Show your support
Give a ⭐️ if this project helped you!
## 📝 License
Copyright © 2020 [Ryohei Machida ](https://github.com/Kogia-sima ).
2022-02-19 00:47:00 -05:00
This project is [MIT ](https://github.com/rust-sailfish/sailfish/blob/master/LICENSE ) licensed.
2020-06-04 16:39:33 -04:00
***
_This README was generated with ❤️ by [readme-md-generator ](https://github.com/kefranabg/readme-md-generator )_