Skip to main content

render_section_block_with_overrides

Function render_section_block_with_overrides 

Source
pub fn render_section_block_with_overrides(
    title: &str,
    body: &str,
    frame_style: SectionFrameStyle,
    unicode: bool,
    width: Option<usize>,
    render: SectionRenderContext<'_>,
    tokens: SectionStyleTokens,
) -> String
Expand description

Renders one titled section body with the requested frame and style tokens.

The returned text is newline-free at the end so callers can compose several sections without trimming renderer output.

ยงExamples

use osp_cli::ui::section_chrome::{
    SectionFrameStyle, SectionRenderContext, SectionStyleTokens,
    render_section_block_with_overrides,
};
use osp_cli::ui::style::{StyleOverrides, StyleToken};
use osp_cli::ui::theme::resolve_theme;

let theme = resolve_theme("plain");
let rendered = render_section_block_with_overrides(
    "Errors",
    "- bad",
    SectionFrameStyle::TopBottom,
    false,
    Some(18),
    SectionRenderContext {
        color: false,
        theme: &theme,
        style_overrides: &StyleOverrides::default(),
    },
    SectionStyleTokens::same(StyleToken::MessageError),
);

assert!(rendered.contains("Errors"));
assert!(rendered.contains("- bad"));