Struct term_transcript::svg::Template [−][src]
pub struct Template<'a> { /* fields omitted */ }
This is supported 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
impl<'a> Template<'a>
[src]
impl<'a> Template<'a>
[src]pub fn new(options: TemplateOptions) -> Self
[src]
pub fn new(options: TemplateOptions) -> Self
[src]Initializes the template based on provided options
.
pub fn render<W: Write>(
&mut self,
transcript: &'a Transcript,
destination: W
) -> Result<(), RenderError>
[src]
pub fn render<W: Write>(
&mut self,
transcript: &'a Transcript,
destination: W
) -> Result<(), RenderError>
[src]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).