Struct skyline_web::Ramhorns

source ·
pub struct Ramhorns { /* private fields */ }
Expand description

Aggregator for Templates, that allows them to be loaded from the file system and use partials: {{>partial}}

Implementations

Loads all the .html files as templates from the given folder, making them accessible via their path, joining partials as required.

let tpls = Ramhorns::from_folder("./templates").unwrap();
let content = "I am the content";
let rendered = tpls.get("hello.html").unwrap().render(&content);

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::lazy("./templates").unwrap();
let content = "I am the content";
let rendered = tpls.from_file("hello.html").unwrap().render(&content);

Get the template with the given name, if it exists.

Get the template with the given name. If the template doesn’t exist, it will be loaded from file and parsed first.

Use this method in tandem with lazy.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.