Struct inapi::Template
[−]
[src]
pub struct Template { /* fields omitted */ }Primitive for rendering templates into uploadable files.
Examples
let template = Template::new("/path/to/template").unwrap(); let data = MapBuilder::new().insert_str("key", "value").build(); let rendered_file = template.render_data(&data).unwrap();
To upload the rendered file to your host, you can pass it
straight into the File primitive:
let mut host = Host::connect("hosts/myhost.json").unwrap(); let file = File::new(&mut host, "/path/to/remote/file").unwrap(); file.upload_file(&mut host, rendered_file, None).unwrap();
Methods
impl Template[src]
fn new<P: AsRef<Path>>(path: P) -> Result<Template, Error>[src]
Create a new File struct.
fn render<T: Encodable>(&self, data: &T) -> Result<File, Error>[src]
Render template to file using generic Encodable data.
fn render_data(&self, data: &Data) -> Result<File, Error>[src]
Render template to file using a Data instance.