pub fn render_with_output<T: Serialize>(
template: &str,
data: &T,
theme: &Theme,
mode: OutputMode,
) -> Result<String, Error>Expand description
Renders a template with explicit output mode control.
Use this when you need to override automatic terminal detection,
for example when honoring a --output=text CLI flag. 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 stylingmode- Output mode:Auto,Term, orText
§Example
use standout::{render_with_output, Theme, OutputMode};
use console::Style;
use serde::Serialize;
#[derive(Serialize)]
struct Data { status: String }
let theme = Theme::new().add("ok", Style::new().green());
// Force plain text output
let plain = render_with_output(
r#"[ok]{{ status }}[/ok]"#,
&Data { status: "done".into() },
&theme,
OutputMode::Text,
).unwrap();
assert_eq!(plain, "done"); // No ANSI codes
// Force terminal output (with ANSI codes)
let term = render_with_output(
r#"[ok]{{ status }}[/ok]"#,
&Data { status: "done".into() },
&theme,
OutputMode::Term,
).unwrap();
// Contains ANSI codes for green