Releases: maciejhirsz/ramhorns
Releases · maciejhirsz/ramhorns
0.9.3
- Added
[ramhorns(flatten)]
that works similar to#[serde(flatten)]
, allowing composed structs to act as a single mapping inside templates. This is best illustrated with an example:#[derive(Content)] pub struct Parent<'a> { title: &'a str, #[ramhorns(flatten)] child: Child<'a>, } #[derive(Content)] pub struct Child<'a> { body: &'a str, } let tpl = Template::new("<h1>{{title}}</h1><head>{{body}}</head>").unwrap(); let html = tpl.render(&Parent { title: "This is the title", child: Child { body: "This is the body", } }); assert_eq!(html, "<h1>This is the title</h1><head>This is the body</head>");
0.9.2
- @grego added serde-esque attributes to the derive macro, to allow struct fields to be renamed or skipped in templates (#30).
#[derive(Content)] struct Data<'a> { #[ramhorns(skip)] secret: &'a str, #[ramhorns(rename = "new")] old: &'a str, }
- Ramhorns is now using Logos in it's parser. Combined with some other refactoring it improved parsing throughput immensely.
0.9.1
0.9.0
- Removed
Template::from_file
, you can still useTemplate::new
to create local templates from strings. Templates
has been renamed toRamhorns
.- Added
Ramhorns::lazy
andRamhorns::from_file
, which allows you to do whatTemplate::from_file
could do before:
use ramhorns::Ramhorns;
let mut tpls = Ramhorns::lazy("./templates").unwrap();
let tpl = tpls.from_file("hello.html").unwrap();
0.8.1
- Reduced memory footprint of the
Template
struct. Templates
internal hash map is now using a faster hashing algorithm.
0.8.0
0.7.1
0.7.0
0.6.1
Error
now implementsstd::error::Error
.