Function sauron::prelude::styles_flag [−][src]
pub fn styles_flag<V, MSG, P>(
trio: P
) -> Attribute<&'static str, &'static str, AttributeValue<MSG>> where
V: Into<Value> + Clone,
P: AsRef<[(&'static str, V, bool)]>,
Expand description
A helper function which creates a style attribute by assembling only the parts that passed the boolean flag.
Examples
use sauron::prelude::*;
let is_active = true;
let display:Attribute<()> = styles_flag([
("display", "block", is_active),
("display", "none", !is_active),
]);
This could also be written as
use sauron::prelude::*;
let is_active = true;
let display:Attribute<()> =
styles([("display", if is_active { "block" }else{ "none" })]);