pub struct Template { /* private fields */ }
Available 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.

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

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.