Skip to main content

Crate ruitl

Crate ruitl 

Source
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 in ruitl.toml.
cli
Command-line interface for RUITL
codegen
Template → Rust code generator — re-exported from the shared ruitl_compiler crate. RUITL Code Generator
component
Component system for RUITL
config
Configuration system for RUITL projects
defaults
Default configuration
dev
ruitl dev subcommand implementation — file watcher + SSE reload sidecar. Gated on both the dev and server features since it needs hotwatch and hyper. 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_compiler crate. 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 with features = ["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 to str via .to_string() or Html::render() — whichever the caller hands in.
assert_renders_to
Convenience: assert a rendered Html (or &str) exactly matches expected. Mostly useful for trivial leaf components; larger diffs belong in insta snapshots.
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