百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

sailfish

> 编程语言
开源

用于 Rust 的简单、小巧且极其快速的模板引擎

987 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

用于 Rust 的简单、小巧且极其快速的模板引擎

✨ Features

  • Simple and intuitive syntax inspired by EJS
  • Include another template file inside template
  • Built-in filters
  • Minimal dependencies ( Template file (templates/hello.stpl):

  
    
      

Code:

```rust
use sailfish::TemplateSimple;

#[derive(TemplateSimple)]
#[template(path = "hello.stpl")]
struct HelloTemplate {
    messages: Vec
}

fn main() {
    let ctx = HelloTemplate {
        messages: vec![String::from("foo"), String::from("bar")],
    };
    println!("{}", ctx.render_once().unwrap());
}

Or use the more powerful Template/TemplateMut/TemplateOnce:

Template file (templates/hello.stpl):


  
    
      

Code:

```rust
use sailfish::Template;

#[derive(Template)]
#[template(path = "hello.stpl")]
struct HelloTemplate {
    messages: Vec
}

impl HelloTemplate {
    fn say_hello(&self) -> String {
        String::from("Hello!")
    }
}

fn main() {
    let ctx = HelloTemplate {
        messages: vec![String::from("foo"), String::from("bar")],
    };
    println!("{}", ctx.render().unwrap());
}

You can find more examples in examples directory.

Roadmap

  • Template trait (RFC)
  • Template inheritance (block, partials, etc.)

Author

Ryohei Machida

  • GitHub: @Kogia-sima

Contributing

Contributions, issues and feature requests are welcome!

Since sailfish is an immature library, there are many planned features 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 issues with Status: PR Welcome label, and let's create a new pull request!

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

Documentation Deployment Instructions

sudo apt install mkdocs mkdocs-material
cd sailfish_root_folder &&
cd docs && cd en 
mkdocs build

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rustrusttemplate-engine

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言