pub struct Ramhorns<H = BuildHasherDefault<FnvHasher>> { /* private fields */ }Expand description
Implementations§
source§impl<H> Ramhorns<H>where
    H: BuildHasher + Default,
 
impl<H> Ramhorns<H>where
    H: BuildHasher + Default,
sourcepub fn from_folder<P>(dir: P) -> Result<Ramhorns<H>, TemplateError>
 
pub fn from_folder<P>(dir: P) -> Result<Ramhorns<H>, TemplateError>
Loads all the .html files as templates from the given folder, making them
accessible via their path, joining partials as required. If a custom
extension is wanted, see [from_folder_with_extension]
let tpls: Ramhorns = Ramhorns::from_folder("./templates").unwrap();
let content = "I am the content";
let rendered = tpls.get("hello.html").unwrap().render(&content);sourcepub fn from_folder_with_extension<P>(
    dir: P,
    extension: &str
) -> Result<Ramhorns<H>, TemplateError>
 
pub fn from_folder_with_extension<P>( dir: P, extension: &str ) -> Result<Ramhorns<H>, TemplateError>
Loads all files with the extension given in the extension parameter as templates
from the given folder, making them accessible via their path, joining partials as
required.
let tpls: Ramhorns = Ramhorns::from_folder_with_extension("./templates", "mustache").unwrap();
let content = "I am the content";
let rendered = tpls.get("hello.mustache").unwrap().render(&content);sourcepub fn extend_from_folder<P>(&mut self, dir: P) -> Result<(), TemplateError>
 
pub fn extend_from_folder<P>(&mut self, dir: P) -> Result<(), TemplateError>
Extends the template collection with files with .html extension
from the given folder, making them accessible via their path, joining partials as
required.
If there is a file with the same name as a  previously loaded template or partial,
it will not be loaded.
sourcepub fn extend_from_folder_with_extension<P>(
    &mut self,
    dir: P,
    extension: &str
) -> Result<(), TemplateError>
 
pub fn extend_from_folder_with_extension<P>( &mut self, dir: P, extension: &str ) -> Result<(), TemplateError>
Extends the template collection with files with extension
from the given folder, making them accessible via their path, joining partials as
required.
If there is a file with the same name as a  previously loaded template or partial,
it will not be loaded.
sourcepub fn lazy<P>(dir: P) -> Result<Ramhorns<H>, TemplateError>
 
pub fn lazy<P>(dir: P) -> Result<Ramhorns<H>, TemplateError>
Create a new empty aggregator for a given folder. This won’t do anything until
a template has been added using from_file.
let mut tpls: Ramhorns = Ramhorns::lazy("./templates").unwrap();
let content = "I am the content";
let rendered = tpls.from_file("hello.html").unwrap().render(&content);