# Herb Rust Bindings Rust bindings for Herb - An ecosystem of powerful and seamless developer tools for HTML+ERB templates. ## Crates This is a Cargo workspace. `herb` is the binding to the C library, the rest build on top of it. | Crate | Binary | Description | |------------------------------------------|------------------|--------------------------------------------------------------| | [`herb`](./) | `herb-rust` | Bindings to the Herb C library: lexing, parsing, and the AST | | [`herb-config`](./herb-config) | | Shared configuration utilities, reads `.herb.yml` | | [`herb-highlighter`](./herb-highlighter) | `herb-highlight` | Syntax highlighter, snippet renderer and diagnostic renderer | | [`herb-printer`](./herb-printer) | `herb-print` | Printers that reconstruct source from a Herb AST | Each binary sits behind the crate's `cli` feature, so a library consumer does not pull in its dependencies: ```bash cargo build -p herb-highlighter --features herb-highlighter/cli cargo build -p herb-printer --features herb-printer/cli ``` ## Building ### Prerequisites - Rust toolchain - Bundler with Prism gem installed in the parent directory ### Build ```bash make build make release make all ``` ## Usage ### CLI (within the Herb repo) ```bash ./bin/herb-rust version ./bin/herb-rust lex path/to/file.erb ./bin/herb-rust parse path/to/file.erb ``` The other crates ship their own binaries: ```bash cargo run -p herb-highlighter --features herb-highlighter/cli -- path/to/file.html.erb cargo run -p herb-printer --features herb-printer/cli -- path/to/file.html.erb ``` ### As a Library ```rust use herb::{lex, parse}; fn main() { let template = "