pub struct TemplateEngine { /* private fields */ }Expand description
Template engine for loading and processing BATS test templates
Implementations§
Source§impl TemplateEngine
impl TemplateEngine
Sourcepub fn load_templates(&mut self) -> Result<()>
pub fn load_templates(&mut self) -> Result<()>
Load all embedded templates
Sourcepub fn get_template(&self, name: &str) -> Result<&str>
pub fn get_template(&self, name: &str) -> Result<&str>
Get a template by name
Sourcepub fn substitute(
&self,
template: &str,
variables: &HashMap<String, String>,
) -> String
pub fn substitute( &self, template: &str, variables: &HashMap<String, String>, ) -> String
Substitute variables in a template Variables are in the format ${VARIABLE_NAME}
Sourcepub fn render(
&self,
template_name: &str,
variables: &HashMap<String, String>,
) -> Result<String>
pub fn render( &self, template_name: &str, variables: &HashMap<String, String>, ) -> Result<String>
Get template by name and substitute variables
Sourcepub fn available_templates(&self) -> Vec<String>
pub fn available_templates(&self) -> Vec<String>
List all available template names
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TemplateEngine
impl RefUnwindSafe for TemplateEngine
impl Send for TemplateEngine
impl Sync for TemplateEngine
impl Unpin for TemplateEngine
impl UnwindSafe for TemplateEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more