pub trait Register where
Self: Sized, {
fn register_helpers(self) -> Result<Self> { ... }
fn load(self, config: &DTConfig) -> Result<Self> { ... }
fn render<S: Serialize>(&self, name: &str, ctx: &Rc<S>) -> Result<Vec<u8>> { ... }
fn update<S: Serialize>(&mut self, name: &str, ctx: &Rc<S>) -> Result<()> { ... }
fn get(&self, name: &str) -> Result<Vec<u8>> { ... }
}Expand description
A registry should hold an environment of templates, and a cached storing the rendered contents.
Provided methods
fn register_helpers(self) -> Result<Self>
fn register_helpers(self) -> Result<Self>
Registers DT’s built-in helpers.
Load templates and render them into cached storage, items that are not
templated (see is_templated) will not be registered into templates
but directly stored into the rendered cache.
Returns the content of an item rendered with given rendering context. This does not modify the stored content.
Rendering only happens if this item is considered as a plain text
file. If this item is considered as a binary file, it’s original
content is returned. The content type is inspected via the
content_inspector crate. Although it can correctly determine if
an item is binary or text mostly of the time, it is just a heuristic
check and can fail in some cases, e.g. NUL byte in the first 1024
bytes of a UTF-8-encoded text file, etc.. See the crate’s home page
for the full caveats.
Updates the stored content of an item with the new content rendered with given rendering context.