1 unstable release

0.1.0 Jan 10, 2024

#674 in Template engine

MIT license

36KB
912 lines

Ibex

Ibex provides ergonomic HTML templating in Rust for SSG/SSR, using procedural macros.

Still a work in progress.

Check out Ibex Template for a quick start.

Example

fn at_blog(blog: BlogPost) -> Document {
    // Creates a `View` and converts to `Document`
    view! {
        // Calls a function `header(true)`
        @header[true]

        // Some html elements
        h2 { [blog.title] }
        h3 { i {[blog.author]} }

        // Include any variables in scope
        p {
            [blog.body]
        }

        // Variables can be used in attributes
        // Use a slash to signify an empty element body
        img [src=blog.image]/

        // Any syntax can be used with `if` or `for` statements (except `else-if`)
        [:if let Some(image_src) = blog.image {
            image [src=image_src]/
        }]
    }
    .into()
}

Ibex logo

Dependencies

~5MB
~88K SLoC