SnapFire is a Rust library that wires the Tera 2 template engine into an Actix Web application and adds live reload for development. You set it up once at startup with a fluent builder, share the resulting TeraWeb handle with your handlers and return rendered templates straight from them.
TeraWeb::builder() takes a glob for your template files. The builder lets you add globals that every template can see (add_global) and register your own filters, functions, tests and components (configure_tera). Tera 2 resolves those names while parsing templates, so an unknown filter fails build() at startup instead of turning up on a later request. TeraWeb::render returns a Template value that implements Actix's Responder, so a handler just returns it and the render happens when Actix sends the response.
Live reload lives behind the devel feature, which is off by default. With it on, SnapFire watches your templates, runs a WebSocket route and injects a small script into pages; when you save a template, the browser reloads. watch_static swaps changed stylesheets in place without a navigation. With the feature off, all of that is compiled out and the same builder calls become no-ops, so your code needs no #[cfg] attributes. If your pages run under a CSP nonce, you can place the reload script yourself with auto_inject_script and TeraWeb::reload_script.
[]
= "0"
= "4"
= "2"Version 0.5 moved to Tera 2, which changed both the Rust API and the template language. SnapFire is also the name of a larger project that grew out of this crate and now includes SnapFire FSR, a full-stack web framework; this crate remains the Tera renderer within it.
Licensed under MPL-2.0. Source at https://github.com/excsn/snapfire and API docs at https://docs.rs/snapfire.
