Skip to main content

facet_html

Function facet_html 

Source
pub fn facet_html(facet: &Facet<'_>, opts: &Emit) -> String
Expand description

A facet as a labelled list of values.

use makeover_layout::{Facet, FacetValue, Selecting, Standing};
use makeover_webview::{Emit, facet::facet_html};

let values = [
    FacetValue::new("music", "Music")
        .standing(Standing::Taken)
        .counted(128)
        .at(0, true),
    FacetValue::new("music/synths", "Synths").at(1, false),
];
let facet = Facet::new("Tag", Selecting::Subtree, &values);
let html = facet_html(&facet, &Emit::default());

assert!(html.contains(r#"data-selecting="subtree""#));
assert!(html.contains(r#"data-facet-value="music/synths""#));
// A subtree is the one mode that offers a way to prune a branch out.
assert!(html.contains("facet-prune"));

A Selecting::Text or Selecting::Range facet lists nothing, so what comes back is the panel and its name with an empty list inside it. That is deliberate rather than an empty string: the app puts its own box in the panel, and the panel is what gives the box the group label and the shared geometry.