Struct term_transcript::svg::Template
source · [−]pub struct Template { /* private fields */ }
Available on crate feature
svg
only.Expand description
Template for rendering Transcript
s into an SVG image.
Examples
use term_transcript::{svg::*, Transcript, UserInput};
let mut transcript = Transcript::new();
transcript.add_interaction(
UserInput::command("test"),
"Hello, \u{1b}[32mworld\u{1b}[0m!",
);
let template_options = TemplateOptions {
palette: NamedPalette::Dracula.into(),
..TemplateOptions::default()
};
let mut buffer = vec![];
Template::new(template_options).render(&transcript, &mut buffer)?;
let buffer = String::from_utf8(buffer)?;
assert!(buffer.contains(r#"Hello, <span class="fg2">world</span>!"#));
Implementations
sourceimpl Template
impl Template
sourcepub fn new(options: TemplateOptions) -> Self
pub fn new(options: TemplateOptions) -> Self
Initializes the template based on provided options
.
sourcepub fn render<W: Write>(
&self,
transcript: &Transcript,
destination: W
) -> Result<(), RenderError>
pub fn render<W: Write>(
&self,
transcript: &Transcript,
destination: W
) -> Result<(), RenderError>
Renders the transcript
as an SVG image.
Errors
Returns a Handlebars rendering error, if any. Normally, the only errors could be related to I/O (e.g., the image cannot be written to a file).
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Template
impl Send for Template
impl Sync for Template
impl Unpin for Template
impl !UnwindSafe for Template
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more