herb

Crates.ioherb
lib.rsherb
version0.8.8
created_at2025-11-02 17:51:22.852644+00
updated_at2026-01-18 23:25:49.673447+00
descriptionRust bindings for Herb
homepage
repositoryhttps://github.com/marcoroth/herb
max_upload_size
id1913394
size3,271,066
Marco Roth (marcoroth)

documentation

README

Herb Rust Bindings

Rust bindings for Herb - Powerful and seamless HTML-aware ERB parsing and tooling.

Building

Prerequisites

  • Rust toolchain
  • Bundler with Prism gem installed in the parent directory

Build

make build        # Build debug binary
make release      # Build release binary
make all          # Generate templates and build

Usage

CLI (within the Herb repo)

./bin/herb-rust version

./bin/herb-rust lex path/to/file.erb

./bin/herb-rust parse path/to/file.erb

As a Library

use herb::{lex, parse};

fn main() {
  let template = "<h1><%= title %></h1>";

  match lex(template) {
    Ok(result) => { println!("{}", result); }
    Err(error) => { eprintln!("Lex error: {}", error); }
  }

  match parse(template) {
    Ok(result) => { println!("{}", result); }
    Err(error) => { eprintln!("Parse error: {}", error); }
  }
}

Testing

cargo test

Publishing

Before publishing to crates.io, vendor the C sources:

make vendor                        # Vendor C sources from ../src and prism
cargo publish --allow-dirty        # Publish to crates.io

The vendor/ directory is gitignored to avoid committing duplicate files. The make vendor task copies C sources from the parent directory into vendor/libherb and vendor/prism so the published crate is self-contained.

Cleaning

make clean
Commit count: 989

cargo fmt