ramhorns

Fast Mustache template engine implementation in pure Rust.

MPL-2.0 License

Downloads
225.1K
Stars
283
Committers
6

Bot releases are hidden (Show)

ramhorns - 1.0.0 Latest Release

Published by maciejhirsz 7 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

ramhorns - 0.14.0

Published by maciejhirsz over 2 years 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).
ramhorns - 0.13.0

Published by maciejhirsz almost 3 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)
ramhorns - 0.12.0

Published by maciejhirsz over 3 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.
ramhorns - 0.11.0

Published by maciejhirsz over 3 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.
ramhorns - 0.10.2

Published by maciejhirsz about 4 years ago

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

Published by maciejhirsz about 4 years ago

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

ramhorns - 0.10.0

Published by maciejhirsz about 4 years ago

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

Published by maciejhirsz over 4 years ago

  • This is a minor patch that reduces compile times for nested data structures (#33).
ramhorns - 0.9.3

Published by maciejhirsz over 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>");
    
ramhorns - 0.9.2

Published by maciejhirsz over 4 years ago

  • @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.
ramhorns - 0.9.1

Published by maciejhirsz over 4 years ago

  • Implemented Content for beef variants of Cow (#28).
  • Removed some unsafe code from template parsing (#14 #29).
ramhorns - 0.9.0

Published by maciejhirsz over 4 years ago

  • 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();
ramhorns - 0.8.1

Published by maciejhirsz over 4 years ago

  • Reduced memory footprint of the Template struct.
  • Templates internal hash map is now using a faster hashing algorithm.
ramhorns - 0.8.0

Published by maciejhirsz over 4 years ago

  • Content can now be implemented for unsized types (#22).
  • Reduced type recursion occurring when rendering nested sections (#23).
ramhorns - 0.7.1

Published by maciejhirsz over 4 years ago

  • 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).
ramhorns - 0.7.0

Published by maciejhirsz over 4 years ago

  • This update allows sections to reference fields from parent scope as per Mustache documentation, big thanks to @grego for his work on #18.
ramhorns - 0.6.1

Published by maciejhirsz over 4 years ago

  • Error now implements std::error::Error.
ramhorns - 0.6.0

Published by maciejhirsz over 4 years ago

  • 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!

ramhorns - 0.5.0

Published by maciejhirsz over 5 years ago

  • Added zero-copy CommonMark support with #[md] attribute.
  • Added {{& variable}} as an alternative to {{{ variable }}} for unescaped printing.