pub fn render_with_mode<T: Serialize>(
template: &str,
data: &T,
theme: &Theme,
output_mode: OutputMode,
color_mode: ColorMode,
) -> Result<String, RenderError>Expand description
Renders a template with explicit output mode and color mode control.
Use this when you need to force a specific color mode (light/dark), for example in tests or when honoring user preferences.
§Arguments
template- A minijinja template stringdata- Any serializable data to pass to the templatetheme- Theme definitions to use for thestylefilteroutput_mode- Output mode:Auto,Term,Text, etc.color_mode- Color mode:LightorDark
§Example
use standout_render::{render_with_mode, Theme, OutputMode, ColorMode};
use console::Style;
use serde::Serialize;
#[derive(Serialize)]
struct Data { status: String }
let theme = Theme::new()
.add_adaptive(
"panel",
Style::new(),
Some(Style::new().black()), // Light mode
Some(Style::new().white()), // Dark mode
);
// Force dark mode rendering
let dark = render_with_mode(
r#"[panel]{{ status }}[/panel]"#,
&Data { status: "test".into() },
&theme,
OutputMode::Term,
ColorMode::Dark,
).unwrap();
// Force light mode rendering
let light = render_with_mode(
r#"[panel]{{ status }}[/panel]"#,
&Data { status: "test".into() },
&theme,
OutputMode::Term,
ColorMode::Light,
).unwrap();