Skip to content

Releases: maciejhirsz/ramhorns

0.9.3

02 May 19:30
Compare
Choose a tag to compare
  • 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

24 Apr 17:33
Compare
Choose a tag to compare
  • @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

20 Apr 08:27
9ea1886
Compare
Choose a tag to compare
  • Implemented Content for beef variants of Cow (#28).
  • Removed some unsafe code from template parsing (#14 #29).

0.9.0

17 Mar 08:18
Compare
Choose a tag to compare
  • Removed Template::from_file, you can still use Template::new to create local templates from strings.
  • Templates has been renamed to Ramhorns.
  • Added Ramhorns::lazy and Ramhorns::from_file, which allows you to do what Template::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

13 Mar 22:21
de659da
Compare
Choose a tag to compare
  • Reduced memory footprint of the Template struct.
  • Templates internal hash map is now using a faster hashing algorithm.

0.8.0

13 Mar 18:54
Compare
Choose a tag to compare
  • Content can now be implemented for unsized types (#22).
  • Reduced type recursion occurring when rendering nested sections (#23).

0.7.1

10 Mar 22:11
85f7385
Compare
Choose a tag to compare
  • Fixed a bug where an inverse section such as {{^foo}}missing{{/foo}} would not render if the field foo (or a key "foo" in a HashMap etc.) was missing in the Content (#21).

0.7.0

10 Mar 19:01
1049831
Compare
Choose a tag to compare
  • This update allows sections to reference fields from parent scope as per Mustache documentation, big thanks to @grego for his work on #18.

0.6.1

05 Feb 17:26
9b30e2d
Compare
Choose a tag to compare
  • Error now implements std::error::Error.

0.6.0

04 Feb 11:26
Compare
Choose a tag to compare
  • Added support for partials using the {{> file_descriptor}} syntax.
  • Added Templates API for processing entire folders, including partials, at once.

Thanks to @grego for the PR #16!