Function sauron::html::attributes::styles_flag
source · [−]pub fn styles_flag<MSG>(
trio: impl IntoIterator<Item = (impl ToString, impl Into<Value>, bool)>
) -> Attribute<&'static str, &'static str, AttributeValue<MSG>>
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" })]);