pub fn render<T: Serialize>(
template: &str,
data: &T,
theme: &Theme,
) -> Result<String, Error>Expand description
Renders a template with automatic terminal color detection.
This is the simplest way to render styled output. It automatically detects whether stdout supports colors and applies styles accordingly. Color mode (light/dark) is detected from OS settings.
§Arguments
template- A minijinja template stringdata- Any serializable data to pass to the templatetheme- Theme definitions to use for thestylefilter
§Example
use standout::{render, Theme};
use console::Style;
use serde::Serialize;
#[derive(Serialize)]
struct Data { message: String }
let theme = Theme::new().add("ok", Style::new().green());
let output = render(
r#"[ok]{{ message }}[/ok]"#,
&Data { message: "Success!".into() },
&theme,
).unwrap();