Macro horrorshow::labels [] [src]

macro_rules! labels {
    ($($tail:tt)+) => { ... };
}

Utility macro for generating a space-delimited string from a set of labels; some of which may be conditionally included into the final string. Labels are anything that implements the RenderOnce trait (e.g. String or &str).

This macro is an alias of: labels_sep_by!(" "; maybe_label,...)

Usage: labels!(maybe_label,...)

  • maybe_label -- Either label_expression, or label_expression => cond_test.

  • label_expression -- An expression that returns a label that implements the RenderOnce trait (e.g. String or &str).

  • label_expression => cond_test -- Conditionally include label_expression whenever cond_test is true. cond_test is an expression that returns either true or false.

This useful in generating class attribute as follows:

html! {
    div(class = labels!("active" => true, "button-style")) {
        : "This is a button"
    }
}