Struct string_template_plus::RenderOptions
source · pub struct RenderOptions {
pub wd: PathBuf,
pub variables: HashMap<String, String>,
pub shell_commands: bool,
}
Fields§
§wd: PathBuf
Working Directory for the Shell Commands
variables: HashMap<String, String>
Variables to use for the template
shell_commands: bool
Run Shell Commands for the output or not
Implementations§
source§impl RenderOptions
impl RenderOptions
pub fn render(&self, templ: &Template) -> Result<String, Error>
sourcepub fn render_iter<'a>(&'a self, templ: &'a Template) -> RenderIter<'a> ⓘ
pub fn render_iter<'a>(&'a self, templ: &'a Template) -> RenderIter<'a> ⓘ
Makes a [RenderIter<'a>
] that can generate incremented strings from the given Template
and the RenderOptions
. The Iterator will have -N
appended where N is the number representing the number of instance.
let templ = Template::parse_template("hello {name}").unwrap();
let mut vars: HashMap<String, String> = HashMap::new();
vars.insert("name".into(), "world".into());
let options = RenderOptions {
variables: vars,
..Default::default()
};
let mut names = options.render_iter(&templ);
assert_eq!("hello world-1", names.next().unwrap());
assert_eq!("hello world-2", names.next().unwrap());
assert_eq!("hello world-3", names.next().unwrap());
Trait Implementations§
source§impl Clone for RenderOptions
impl Clone for RenderOptions
source§fn clone(&self) -> RenderOptions
fn clone(&self) -> RenderOptions
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for RenderOptions
impl Debug for RenderOptions
source§impl Default for RenderOptions
impl Default for RenderOptions
source§fn default() -> RenderOptions
fn default() -> RenderOptions
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl RefUnwindSafe for RenderOptions
impl Send for RenderOptions
impl Sync for RenderOptions
impl Unpin for RenderOptions
impl UnwindSafe for RenderOptions
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