Function sauron::styles_flag
source · pub fn styles_flag<MSG>(
trio: impl IntoIterator<Item = (impl Into<Cow<'static, str>>, impl Into<Value>, bool)>
) -> Attribute<MSG>
Expand description
A helper function which creates a style attribute by assembling only the parts that passed the boolean flag.
§Examples
use sauron::*;
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::{*, html::attributes::styles};
let is_active = true;
let display:Attribute<()> =
styles([("display", if is_active { "block" }else{ "none" })]);