Expand description
§RUITL - Rust UI Template Language
A modern template engine for building HTML components and applications in Rust.
§Features
- Component-based: Create reusable HTML components
- Server-side rendering: Deploy as serverless functions or containers
- Static generation: Generate static HTML files
- Compiled templates: High-performance compiled Rust code
- No JavaScript: Pure Rust, no client-side JS required
- Great DX: IDE autocompletion and type safety
§Quick Start
Write a .ruitl template in templates/Hello.ruitl:
component Hello {
props { name: String }
}
ruitl Hello(name: String) {
<div class="greeting">
<h1>{format!("Hello, {}!", name)}</h1>
</div>
}cargo build invokes build.rs, which compiles it to a sibling
templates/Hello_ruitl.rs (checked in, templ-style). Use it from Rust:
ⓘ
use ruitl::prelude::*;
let component = Hello;
let props = HelloProps { name: "World".to_string() };
let ctx = ComponentContext::new();
let html = component.render(&props, &ctx).unwrap();
println!("{}", html.render());Re-exports§
pub use component::Component;pub use component::ComponentContext;pub use component::ComponentProps;pub use component::EmptyProps;pub use error::Result;pub use error::RuitlError;pub use html::Html;pub use html::HtmlAttribute;pub use html::HtmlElement;
Modules§
- build
- Static-site build pipeline driven by
[[routes]]entries inruitl.toml. - cli
- Command-line interface for RUITL
- codegen
- Template → Rust code generator — re-exported from the shared
ruitl_compilercrate. RUITL Code Generator - component
- Component system for RUITL
- config
- Configuration system for RUITL projects
- defaults
- Default configuration
- dev
ruitl devsubcommand implementation — file watcher + SSE reload sidecar. Gated on both thedevandserverfeatures since it needshotwatchandhyper. Development server with browser auto-reload.- error
- Error handling for RUITL
- html
- HTML rendering and manipulation utilities
- parser
- Parser AST and tokenizer — re-exported from the shared
ruitl_compilercrate. RUITL Template Parser - prelude
- Prelude module for convenient imports
- testing
- Test-support helpers (
ComponentTestHarness,HtmlAssertion,assert_html_contains!,assert_renders_to!). Feature-gated so they don’t bloat release binaries — consumers enable withfeatures = ["testing"]in their[dev-dependencies]. Always available inside this crate’s own tests. Component testing utilities.
Macros§
- assert_
html_ contains - Convenience: assert a rendered
Html(or&String/&str) contains a substring. Works on anything that derefs tostrvia.to_string()orHtml::render()— whichever the caller hands in. - assert_
renders_ to - Convenience: assert a rendered
Html(or&str) exactly matchesexpected. Mostly useful for trivial leaf components; larger diffs belong ininstasnapshots. - impl_
component - Macro for implementing common component patterns
- impl_
static_ component - Macro for implementing static components
Constants§
- VERSION
- Library version
Functions§
- init
- Initialize RUITL with default configuration