Crate rusty_handlebars

Source
Expand description

Rusty Handlebars - A type-safe Handlebars templating engine for Rust

This crate provides a type-safe implementation of the Handlebars templating engine with a focus on compile-time template processing and HTML safety.

§Features

  • Type-safe templating with compile-time validation
  • HTML escaping for secure output
  • Optional HTML minification
  • Derive macro support for easy integration
  • Flexible display traits for both regular and HTML-safe output
  • Optional parser functionality

§Examples

use rusty_handlebars::WithRustyHandlebars;

#[derive(WithRustyHandlebars)]
#[template(path = "templates/hello.hbs")]
struct HelloTemplate {
    name: String,
}

For HTML-safe output:

use rusty_handlebars::AsDisplayHtml;

let html = "<script>alert('xss')</script>";
let safe_html = html.as_display_html().to_string();
// Output: &lt;script&gt;alert(&#x27;xss&#x27;)&lt;/script&gt;

Re-exports§

pub use as_bool::AsBool;

Modules§

as_bool
Boolean conversion trait for various Rust types

Traits§

AsDisplay
Trait for converting values to a Display implementation
AsDisplayHtml
Trait for converting values to an HTML-safe Display implementation
WithRustyHandlebars
Trait that must be implemented for types that can be used with Handlebars templates

Derive Macros§

WithRustyHandlebars
Derive macro for implementing Handlebars templating on structs Derive macro for implementing Handlebars templating