Macro horrorshow::labels [−][src]
macro_rules! labels {
($($tail : tt) +) => { ... };
}
Expand description
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
– Eitherlabel_expression
, orlabel_expression => cond_test
. -
label_expression
– An expression that returns a label that implements theRenderOnce
trait (e.g.String
or&str
). -
label_expression => cond_test
– Conditionally includelabel_expression
whenevercond_test
istrue
.cond_test
is an expression that returns eithertrue
orfalse
.
This useful in generating class attribute as follows:
html! {
div(class = labels!("active" => true, "button-style")) {
: "This is a button"
}
}