Skip to main content

render

Function render 

Source
pub fn render(
    sources: Vec<(String, CanonicalValue)>,
    to_json: bool,
) -> Result<String, Box<dyn Error>>
Expand description

Renders the loaded sources as formatted tables or as JSON.

ยงExamples

use sheeter_engine::view;
use std::fs;

let dir = tempfile::tempdir().unwrap();
fs::write(dir.path().join("a.csv"), "x\n1\n").unwrap();
let expanded = view::expand(dir.path().join("a.csv").to_str().unwrap()).unwrap();
let json = view::render(expanded, true).unwrap();
assert_eq!(json.trim(), r#"[{"x":"1"}]"#);