render_to_format

Function render_to_format 

Source
pub fn render_to_format(
    template: &str,
    vars: HashMap<&str, &str>,
    format: OutputFormat,
) -> Result<String>
Expand description

Render template to specific output format

§Arguments

  • template - Template string
  • vars - Variables as key-value pairs
  • format - Desired output format

§Example

use clnrm_template::{render_to_format, OutputFormat};
use std::collections::HashMap;

let mut vars = HashMap::new();
vars.insert("name", "test");
vars.insert("value", "123");

let result = render_to_format("Name: {{ name }}, Value: {{ value }}", vars, OutputFormat::Json).unwrap();