Handlebars templating libraries now works with Serde data
Posted on Rust Users Forum by sunng :Just a quick update on my handlebars libraries: You can now use serde for template data.
This is implemented via a feature called
serde_type
. Internally we useserde_json::value::Value
as data type which is pretty similar to theJson
enum in rustc_serialize. Anything implementsserde::ser::Serialize
can be rendered. To use serde for handlebars-iron, configure your Cargo.toml like this:[features] default = ["handlebars-iron/serde_type"]
The API is fully compatible with default one so you don't have to change any code except the data type.
handlebars core: github.com/sunng87/handlebars-rust handlebar iron middleware: github.com/sunng87/handlebars-iron