2020-06-04 16:39:33 -04:00
< div align = "center" >
![SailFish ](./resources/logo.png )
Simple, small, and extremely fast template engine for Rust
2020-12-17 01:50:47 -05:00
[![Tests ](https://github.com/Kogia-sima/sailfish/workflows/Tests/badge.svg )](https://github.com/Kogia-sima/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)
2021-01-01 12:05:01 -05:00
![Dependency counts ](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/Kogia-sima/a2128afe12bf05d85a0d68346236a4f5/raw/sailfish-dep-counts.json )
2021-01-04 15:28:53 -05:00
[![dependency status ](https://deps.rs/repo/github/Kogia-sima/sailfish/status.svg )](https://deps.rs/repo/github/Kogia-sima/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)
2020-06-05 10:42:06 -04:00
[![License: MIT ](https://img.shields.io/badge/License-MIT-yellow.svg )](https://github.com/Kogia-sima/sailfish/blob/master/LICENSE)
2020-06-09 08:48:39 -04:00
[User Guide ](https://sailfish.netlify.app/en/ ) | [API Docs ](https://docs.rs/sailfish ) | [Examples ](./examples )
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]
2021-03-28 19:28:36 -04:00
sailfish = "0.3.2"
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
2020-06-07 00:41:08 -04:00
- `Template` trait ([RFC](https://github.com/Kogia-sima/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!
2020-06-19 05:27:19 -04:00
Since sailfish is an immature library, there are many [planned features ](https://github.com/Kogia-sima/sailfish/labels/Type%3A%20RFC ) that is on a stage of RFC. Please leave a comment if you have an idea about its design!
Also I welcome any pull requests to improve sailfish! Find issue with [Status: PR Welcome ](https://github.com/Kogia-sima/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/Kogia-sima/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 ).
This project is [MIT ](https://github.com/Kogia-sima/sailfish/blob/master/LICENSE ) licensed.
***
_This README was generated with ❤️ by [readme-md-generator ](https://github.com/kefranabg/readme-md-generator )_