classes!() { /* proc-macro */ }
Expand description
Wraps multiple values implementing Render
into one, with whitespace as the delimiter.
This macro behaves similarly to the frag!
macro. The only difference is that all wrapped
values will be rendered sequentially in the order of arguments, but with a single whitespace
character ' '
to delimit each value.
It is intended to be used to generate an interpolated string for the class
attribute in an
HTML markup.
Example
The following example generates a class string with several values interpolated. Note that
four
is not included because it is None
, but the whitespace that delimits four
is
still rendered regardless.
let two = Some("two");
let four: Option<&str> = None;
let six = 6;
let s = classes!("one", two, "three", four, "five", six);
assert_eq!(render!(s), "one two three five 6");