Skip to main content

render_display_template

Function render_display_template 

Source
pub fn render_display_template(
    template: &str,
    object: &impl DisplayFieldLookup,
    output_budget: &mut usize,
) -> Result<String, DisplayRenderError>
Expand description

Renders one Display template against object.

The template is read once, left to right. Plain text is copied, a {path} placeholder is replaced by object.get_display_value(path), and \ makes the next character literal. Substituted values are never read again, so a value that contains {...} stays as it is.

The rendered size is subtracted from output_budget, which is shared by all fields of one object. If the result would not fit, an error is returned and the budget is set to zero, so the remaining fields of the object fail without being rendered.