Struct term_transcript::svg::Template [−][src]
pub struct Template { /* fields omitted */ }This is supported on crate feature
svg only.Expand description
Template for rendering Transcripts 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
Initializes the template based on provided options.
pub 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).
