)
}
-fn render_row(columns: &[String], rowlike: &mut Rowlike) -> HTML {
+fn render_row(config: &Config, columns: &[String], rowlike: &mut Rowlike) -> HTML {
match rowlike {
Rowlike::Spacer => HTML::from("<tr><th class=\"spacer_row\"></th></tr>\n"),
Rowlike::Row(row) => {
}
}
-fn render_column_headers(columns: &[String]) -> HTML {
+fn render_column_headers(config: &Config, columns: &[String]) -> HTML {
HTML(
String::from(r#"<tr class="key"><th></th>"#)
+ &columns.iter().fold(String::new(), |mut acc, col| {
let columns = column_order(&config, &rows);
Ok(HTML(format!(
"{HEADER}{}{}{FOOTER}",
- render_column_headers(&columns),
+ render_column_headers(&config, &columns),
rows.into_iter()
- .map(|mut r| render_row(&columns, &mut r))
+ .map(|mut r| render_row(&config, &columns, &mut r))
.collect::<HTML>()
)))
}
#[test]
fn test_read_config() {
assert_eq!(
- read_config(&b"!col_threshold 10"[..]).unwrap(),
- Config {
- column_threshold: 10
- }
+ read_config(&b"!col_threshold 10"[..])
+ .unwrap()
+ .column_threshold,
+ 10
);
let bad_num = read_config(&b"!col_threshold foo"[..]);
fn test_render_row() {
assert_eq!(
render_row(
+ &Config {
+ column_threshold: 0,
+ },
&["foo".to_owned()],
&mut Rowlike::Row(Row {
label: "nope".to_owned(),