Macro horrorshow::labels_sep_by
[−]
[src]
macro_rules! labels_sep_by { (@inner_expand $has_before:expr; $sep:expr; $tmpl:ident $item:expr) => { ... }; (@inner_expand $has_before:expr; $sep:expr; $tmpl:ident $item:expr => $should_include:expr) => { ... }; (@inner_expand $has_before:expr; $sep:expr; $tmpl:ident $item:expr, $($tail:tt)+) => { ... }; (@inner_expand $has_before:expr; $sep:expr; $tmpl:ident $item:expr => $should_include:expr, $($tail:tt)+) => { ... }; ($sep:expr; $item:expr) => { ... }; ($sep:expr; $item:expr => $should_include:expr) => { ... }; ($sep:expr; $item:expr, $($tail:tt)+) => { ... }; ($sep:expr; $item:expr => $should_include:expr, $($tail:tt)+) => { ... }; }
Utility macro for generating a delimited string from a set of labels;
some of which may be conditionally included into the final string.
The delimiter/seperator and labels are anything that implements
the RenderOnce
trait (e.g. String
or &str
).
Usage: labels_sep_by!(seperator; maybe_label,...)
-
seperator
-- Delimiter/seperator that implements theRenderOnce
trait (e.g.String
or&str
). -
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 style attribute as follows:
html! { div(style = labels_sep_by!(";"; "color: #000" => true, "font-weight: bold")) { : "This is a button" } }