Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
A safe and simple Rust template engine with JSX ergonomics, type-safe custom components, and automatic HTML escaping.
Render.rs is a type-safe Rust template engine that brings the ergonomics of JSX to HTML and XML rendering by combining trait implementations, structs, and macros.
Render.rs is a Rust crate that unifies tree-shaped data composition through the Render trait. As input, it takes Rust structs and functions annotated with macros like #[component], along with composable element trees built via the rsx! macro; as output, it produces rendered HTML strings via the html! macro or direct .render() calls. The crate is open source under the MIT license and designed specifically for Rust's type system.
Render trait — Any struct implementing this trait becomes a renderable component, enabling custom components with no runtime errors.#[component] macro — Turns a plain Rust function into a component; the function's parameters become struct fields, and visibility flows from the function to the generated struct.rsx! macro — Composes elements with JSX-like syntax inside Rust code, allowing conditional logic and expressions via Rust's normal syntax.html! macro — Convenience macro that builds a component tree with rsx! and immediately renders it to a String; useful for HTTP responses or generated files.render::html_escaping module, and the raw! macro lets you inject unescaped HTML intentionally.pub component function produces a pub struct with pub fields.HTML5Doctype with custom components.Page component taking title and children parameters) and nest them arbitrarily.raw! macro only when you need to inject trusted HTML, preserving both safety and control.Defining a component is as simple as writing a function annotated with #[component]; the macro generates a struct implementing Render. Inside that function, the rsx! macro builds a tree of elements and expressions. Calling the html! macro on a component instance renders the tree to a string, processing attributes and text through the escaping module in the process.
Render.rs is free and open-source, distributed under the MIT license.
Yes, Render.rs is free and open source under the MIT license, so you can use it in commercial and personal projects without cost.
Render.rs provides three main macros: #[component] to define components from functions, rsx! to compose element trees with JSX ergonomics, and html! to render a tree directly to a string.
Attribute values and plain strings are escaped using the render::html_escaping module by default. If you need to insert raw HTML, you can wrap a string in the raw! macro, which bypasses escaping for that value.
Yes, any struct implementing the Render trait is a component. The #[component] macro makes it easy to turn a function into a component, and the rsx! macro lets you compose components and standard HTML elements together.
The current version does not type-check HTML tags or attributes — it accepts any key and string value — focusing instead on type-safe custom component composition. If you need strict HTML spec validation, typed-html may be a better fit.
