Skip to content

Commit 6024b23

Browse files
v0.3: updated the docs & the CSS minification algorithm
1 parent c1f70cc commit 6024b23

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "yew-html-ext"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
edition = "2021"
55
authors = ["Tim Kurdov <[email protected]>"]
66
repository = "https://github.com/schvv31n/yew-html-ext"

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ a number of syntactic extensions. Being a drop-in replacement, all one has to do
99
1. Add it to the project's dependencies
1010
```toml
1111
[dependencies]
12-
yew-html-ext = "0.1"
12+
yew-html-ext = "0.3"
1313
```
1414
2. Replace uses/imports of `yew::html{_nested}` with `yew_html_ext::html{_nested}`
1515

1616
The provided macros facilitate an experimental ground for potential additions to Yew HTML proper,
1717
which is why the base features are untouched, only new ones are added.
18-
The specific syntax provided by the library is explained in [the docs](https://docs.rs/yew-html-ext/latest/yew_html_ext)
18+
The specific syntax provided by the library is explained in
19+
#### [the docs](https://docs.rs/yew-html-ext/latest/yew_html_ext)
1920

2021
## Format this new fancy HTML
2122
[`yew-fmt`](https://github.com/schvv31n/yew-fmt) has support for this extended syntax,

src/lib.rs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
//! ```
5656
//! ## `match` nodes
5757
//! 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.
5959
//! ```rust
6060
//! use yew_html_ext::html;
6161
//! use yew::{Properties, function_component, html::Html};
@@ -74,6 +74,7 @@
7474
//! Ordering::Less => { '<' },
7575
//! Ordering::Equal => { '=' },
7676
//! Ordering::Greater => { '>' },
77+
//! _ => {},
7778
//! }
7879
//! }
7980
//! }
@@ -109,7 +110,7 @@
109110
//! }
110111
//! ```
111112
//! ## `#[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.
113114
//!
114115
//! ```rust
115116
//! use yew_html_ext::html;
@@ -118,12 +119,45 @@
118119
//! #[function_component]
119120
//! fn DebugStmt() -> Html {
120121
//! html! {
121-
//! <code #[cfg(debug_assertions)] style="color: green">
122+
//! <code #[cfg(debug_assertions)] style="color: green;">
122123
//! { "Make sure this is not green" }
123124
//! </code>
124125
//! }
125126
//! }
126127
//! ```
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+
//! ```
127161
128162
mod html_tree;
129163
mod props;

src/props/prop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ fn advance_until_next_dot2(input: &ParseBuffer) -> syn::Result<()> {
267267
/// - Strips all whitespace after a unescaped [semi]colon that's not inside quotes
268268
/// - Removes the final semicolon
269269
pub fn minify_css(mut s: String) -> String {
270-
let mut stripping = false;
270+
let mut stripping = true;
271271
let mut escaped = false;
272272
let mut in_quotes = false;
273273

0 commit comments

Comments
 (0)