sailfish/docs/en/site/search/search_index.json

1 line
20 KiB
JSON
Raw Normal View History

{"config":{"indexing":"full","lang":["en"],"min_search_length":3,"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":"Welcome to Sailfish Documentation! Sailfish is a simple, small, and extremely fast template engine for Rust. This documentation guides you how to get started with sailfish. This documentation mainly focuses on concepts of the library, general usage, and template syntax. If you've read this documentation and need more specific information, you might want to read the sailfish API docs . Why Sailfish ? There are many libraries for template rendering in Rust. Among those libraries, sailfish aims at rapid development and rapid rendering . Sailfish has many features that other libraries might not support. Write a Rust code directly inside templates, supporting many Rust syntax (struct definition, closure, macro invocation, etc.) Built-in filters Minimal dependencies (<15 crates in total) Extremely fast (See benchmarks ) Template rendering is always type-safe because templates are statically compiled. Syntax highlighting ( vscode , vim ) Upcoming features Since sailfish is on early stage of development, there are many upcoming features that is not supported yet. You can find many RFC s in my repository. These RFC include: Template trait (which does not consume itself) Template inheritance (block, partials, etc.) If you have any idea about them or want to implement that feature, please send a comment on the issue! License Copyright \u00a9 2020 Ryohei Machida This project is MIT licensed","title":"Welcome"},{"location":"#welcome-to-sailfish-documentation","text":"Sailfish is a simple, small, and extremely fast template engine for Rust. This documentation guides you how to get started with sailfish. This documentation mainly focuses on concepts of the library, general usage, and template syntax. If you've read this documentation and need more specific information, you might want to read the sailfish API docs .","title":"Welcome to Sailfish Documentation!"},{"location":"#why-sailfish","text":"There are many libraries for template rendering in Rust. Among those libraries, sailfish aims at rapid development and rapid rendering . Sailfish has many features that other libraries might not support. Write a Rust code directly inside templates, supporting many Rust syntax (struct definition, closure, macro invocation, etc.) Built-in filters Minimal dependencies (<15 crates in total) Extremely fast (See benchmarks ) Template rendering is always type-safe because templates are statically compiled. Syntax highlighting ( vscode , vim )","title":"Why Sailfish ?"},{"location":"#upcoming-features","text":"Since sailfish is on early stage of development, there are many upcoming features that is not supported yet. You can find many RFC s in my repository. These RFC include: Template trait (which does not consume itself) Template inheritance (block, partials, etc.) If you have any idea about them or want to implement that feature, please send a comment on the issue!","title":"Upcoming features"},{"location":"#license","text":"Copyright \u00a9 2020 Ryohei Machida This project is MIT licensed","title":"License"},{"location":"getting-started/","text":"Getting Started Prepare the template file Create a new directory named templates in the same directory as Cargo.toml . Copy the following contents and paste it to a new file named templates/hello.stpl . < html > < body > <% for msg in & messages { %> < div > <%= msg %> </ div > <% } %> </ body > </ html > Now your project structure should be like this: Cargo.toml src/ (Source files) templates/ hello.stpl Render the template Import the sailfish crates: use sailfish :: TemplateOnce ; Define the template struct to be rendered: #[derive(TemplateOnce)] // automatically implement `TemplateOnce` trait #[template(path = \"hello.stpl\" )] // specify the path to template struct HelloTemplate { // data to be passed to the template messages : Vec < String > , } Render the data with render_once() method. fn main () { let ctx = HelloTemplate { messages : vec ! [ String :: from