| Crates.io | sailfish-minify |
| lib.rs | sailfish-minify |
| version | 0.10.2 |
| created_at | 2024-06-11 11:49:24.14481+00 |
| updated_at | 2025-12-27 12:58:53.741404+00 |
| description | Hacky but simple minification support for sailfish, using html-minifier by default |
| homepage | https://github.com/pauldotsh/sailfish-minify |
| repository | https://github.com/pauldotsh/sailfish-minify |
| max_upload_size | |
| id | 1268111 |
| size | 27,225 |
Hacky but simple minification support for sailfish, using html-minifier by default
By default, sailfish-minify DOES also minify its components, however if you want to disable this behavior you can compile without "minifiy-components". Also, the components are minified with the "parent" template options, this behavior is however untested when there are multiple parents using the same component but using different minifier options.
use sailfish::TemplateSimple;
#[derive(Debug, sailfish_minify::TemplateSimple)]
#[template(path = "test.stpl")] // Notice the use of templ instead of template
// #[min_with(HTMLMinifier)] // Default is HTMLMinifier anyway
// #[min_with(Custom(html-minifier --collapse-whitespace))] // You can even use custom commands
struct MinifiedTestTemplate<'a> {
s: &'a str
}
#[derive(Debug, TemplateSimple)]
#[template(path = "test.stpl")]
struct TestTemplate<'a> {
s: &'a str
}
fn main() {
println!("Unminified size: {} chars", TestTemplate { s: "test" }.render_once().unwrap().len());
println!("Minified size: {} chars", MinifiedTestTemplate { s: "test" }.render_once().unwrap().len());
}
Output
Unminified size: 2238 chars
Minified size: 23 chars