Ramhorns Versions Save

Fast Mustache template engine implementation in pure Rust.

v1.0.0

2 months ago
  • Ramhorns is now using the MPL-2.0 license (#66, #73)
  • [BREAKING] Ramhorns::get now takes &str as an argument (see #70, #69, thanks to @lcnr for reporting)
  • Added a method to manually insert a template parsed from source by @grego (#67)
  • Added rename_all attribute similar to serde and optional index-based sections by @tiagolobocastro (#63)
  • Implemented Debug for Ramhorns & Template (#72, thanks to @dsaghliani for reporting)
  • Updated dependencies (#64, #68, #71)

Full Changelog: https://github.com/maciejhirsz/ramhorns/compare/v0.14.0...v1.0.0

v0.14.0

1 year ago

This patch adds great work from @grego:

  • You can now nest sections in fields such that instead of writing {{#section}}{{field}}{{/section}} you can just write {{section field}}. You can also use this nesting for opening and closing of sections (#59).
  • The main Ramhorns struct can now take a custom hasher as a generic param for its internal partials HashMap (also #59).
  • Updated dependencies, pulldown_cmark is now an optional dependency (enabled by default).

v0.13.0

2 years ago
  • Breaking: #[md] has been replaced with #[ramhorns(md)] for consistency. (#56)
  • Adds the #[ramhorns(callback = path::to::fn)] attribute which can execute arbitrary code for inserting values into template, see tests/main.rs for an example. (#56, #58)
  • Adds functions extend_from_folder and extend_from_folder_with_extension to include templates from another folder in the collection. (#57)

v0.12.0

2 years ago
  • Added a new error variant: Error::NotFound(Box<str>) which contains the name of a partial for which a template file couldn't be found.

v0.11.0

2 years ago
  • Content is now implemented for arrays and ArrayVec from the arrayvec crate (#49, by @grego).
  • Added Ramhorns::from_folder_with_extension to which allows to use custom file extensions for templates (#46, by @halvko).
  • Updated dependencies.

v0.10.2

3 years ago
  • The #[derive(Content)] macro no longer errors if the Result type has been aliased in current scope (#37).

v0.10.1

3 years ago

Fixes an issue with inverse sections {{^...}} missing parent variables (#36).

v0.10.0

3 years ago
  • Fixes the way missing sections are handled to be consistent with Mustache specification, this is a breaking change (#34).

v0.9.4

3 years ago
  • This is a minor patch that reduces compile times for nested data structures (#33).

v0.9.3

4 years ago
  • 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>");