|
55 | 55 | //! ```
|
56 | 56 | //! ## `match` nodes
|
57 | 57 | //! The syntax is the same as of Rust's `match` expressions; the body of a match arm must have
|
58 |
| -//! exactly 1 node. |
| 58 | +//! exactly 1 node. That node may be just `{}`, which will expand to nothing. |
59 | 59 | //! ```rust
|
60 | 60 | //! use yew_html_ext::html;
|
61 | 61 | //! use yew::{Properties, function_component, html::Html};
|
|
74 | 74 | //! Ordering::Less => { '<' },
|
75 | 75 | //! Ordering::Equal => { '=' },
|
76 | 76 | //! Ordering::Greater => { '>' },
|
| 77 | +//! _ => {}, |
77 | 78 | //! }
|
78 | 79 | //! }
|
79 | 80 | //! }
|
|
109 | 110 | //! }
|
110 | 111 | //! ```
|
111 | 112 | //! ## `#[cfg]` on props of elements & components
|
112 |
| -//! Any number of `#[cfg]` attributes can be applied to any prop of a of an element or component. |
| 113 | +//! Any number of `#[cfg]` attributes can be applied to any prop of an element or component. |
113 | 114 | //!
|
114 | 115 | //! ```rust
|
115 | 116 | //! use yew_html_ext::html;
|
|
118 | 119 | //! #[function_component]
|
119 | 120 | //! fn DebugStmt() -> Html {
|
120 | 121 | //! html! {
|
121 |
| -//! <code #[cfg(debug_assertions)] style="color: green"> |
| 122 | +//! <code #[cfg(debug_assertions)] style="color: green;"> |
122 | 123 | //! { "Make sure this is not green" }
|
123 | 124 | //! </code>
|
124 | 125 | //! }
|
125 | 126 | //! }
|
126 | 127 | //! ```
|
| 128 | +//! ## Any number of top-level nodes is allowed |
| 129 | +//! The limitation of only 1 top-level node per macro invocation of standard Yew is lifted. |
| 130 | +//! |
| 131 | +//! ```rust |
| 132 | +//! use yew_html_ext::html; |
| 133 | +//! use yew::{function_component, Html}; |
| 134 | +//! |
| 135 | +//! #[function_component] |
| 136 | +//! fn Main() -> Html { |
| 137 | +//! html! { |
| 138 | +//! <h1>{"Node 1"}</h1> |
| 139 | +//! <h2>{"Node 2"}</h2> // standard Yew would fail right around here |
| 140 | +//! } |
| 141 | +//! } |
| 142 | +//! ``` |
| 143 | +//! ## Optimisation: minified inline CSS |
| 144 | +//! If the `style` attribute of an HTML element is set to a string literal, that string's contents |
| 145 | +//! are interpreted as CSS & minified, namely, the whitespace between the rules & between the key & |
| 146 | +//! value of a rule is removed, and a trailing semicolon is stripped. |
| 147 | +//! ```rust |
| 148 | +//! use yew_html_ext::html; |
| 149 | +//! use yew::{function_component, Html}; |
| 150 | +//! |
| 151 | +//! #[function_component] |
| 152 | +//! fn DebugStmt() -> Html { |
| 153 | +//! html! { |
| 154 | +//! // the assigned style will be just `"color:green"` |
| 155 | +//! <strong style=" |
| 156 | +//! color: green; |
| 157 | +//! ">{"Hackerman"}</strong> |
| 158 | +//! } |
| 159 | +//! } |
| 160 | +//! ``` |
127 | 161 |
|
128 | 162 | mod html_tree;
|
129 | 163 | mod props;
|
|
0 commit comments