On reflection, the extra spaces around classes feels weird to me. Let's revert that (but keep the 2021 edition migration in place).
This commit is contained in:
parent
49755007da
commit
45157fc58c
4 changed files with 23 additions and 23 deletions
|
@ -155,7 +155,7 @@ and mix and match them with other attributes:
|
||||||
```rust
|
```rust
|
||||||
# let _ = maud::
|
# let _ = maud::
|
||||||
html! {
|
html! {
|
||||||
input #cannon .big .scary .bright-red type="button" value="Launch Party Cannon";
|
input #cannon .big.scary.bright-red type="button" value="Launch Party Cannon";
|
||||||
}
|
}
|
||||||
# ;
|
# ;
|
||||||
```
|
```
|
||||||
|
@ -185,7 +185,7 @@ which otherwise wouldn't parse:
|
||||||
```rust
|
```rust
|
||||||
# let _ = maud::
|
# let _ = maud::
|
||||||
html! {
|
html! {
|
||||||
div ."col-sm-2" { "Bootstrap column!" }
|
div."col-sm-2" { "Bootstrap column!" }
|
||||||
}
|
}
|
||||||
# ;
|
# ;
|
||||||
```
|
```
|
||||||
|
|
|
@ -86,7 +86,7 @@ let severity = "critical";
|
||||||
# let _ = maud::
|
# let _ = maud::
|
||||||
html! {
|
html! {
|
||||||
aside #(name) {
|
aside #(name) {
|
||||||
p .{ "color-" (severity) } { "This is the worst! Possible! Thing!" }
|
p.{ "color-" (severity) } { "This is the worst! Possible! Thing!" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# ;
|
# ;
|
||||||
|
@ -146,7 +146,7 @@ And classes:
|
||||||
let cuteness = 95;
|
let cuteness = 95;
|
||||||
# let _ = maud::
|
# let _ = maud::
|
||||||
html! {
|
html! {
|
||||||
p .cute[cuteness > 50] { "Squee!" }
|
p.cute[cuteness > 50] { "Squee!" }
|
||||||
}
|
}
|
||||||
# ;
|
# ;
|
||||||
```
|
```
|
||||||
|
|
|
@ -189,15 +189,6 @@ fn hyphens_in_attribute_names() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn class_shorthand() {
|
fn class_shorthand() {
|
||||||
let result = html! { p { "Hi, " span .name { "Lyra" } "!" } };
|
|
||||||
assert_eq!(
|
|
||||||
result.into_string(),
|
|
||||||
r#"<p>Hi, <span class="name">Lyra</span>!</p>"#
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn class_shorthand_without_space() {
|
|
||||||
let result = html! { p { "Hi, " span.name { "Lyra" } "!" } };
|
let result = html! { p { "Hi, " span.name { "Lyra" } "!" } };
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.into_string(),
|
result.into_string(),
|
||||||
|
@ -205,9 +196,18 @@ fn class_shorthand_without_space() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn class_shorthand_with_space() {
|
||||||
|
let result = html! { p { "Hi, " span .name { "Lyra" } "!" } };
|
||||||
|
assert_eq!(
|
||||||
|
result.into_string(),
|
||||||
|
r#"<p>Hi, <span class="name">Lyra</span>!</p>"#
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn classes_shorthand() {
|
fn classes_shorthand() {
|
||||||
let result = html! { p { "Hi, " span .name .here { "Lyra" } "!" } };
|
let result = html! { p { "Hi, " span.name.here { "Lyra" } "!" } };
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.into_string(),
|
result.into_string(),
|
||||||
r#"<p>Hi, <span class="name here">Lyra</span>!</p>"#
|
r#"<p>Hi, <span class="name here">Lyra</span>!</p>"#
|
||||||
|
@ -216,7 +216,7 @@ fn classes_shorthand() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hyphens_in_class_names() {
|
fn hyphens_in_class_names() {
|
||||||
let result = html! { p .rocks-these .are--my--rocks { "yes" } };
|
let result = html! { p.rocks-these.are--my--rocks { "yes" } };
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.into_string(),
|
result.into_string(),
|
||||||
r#"<p class="rocks-these are--my--rocks">yes</p>"#
|
r#"<p class="rocks-these are--my--rocks">yes</p>"#
|
||||||
|
@ -225,7 +225,7 @@ fn hyphens_in_class_names() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn class_string() {
|
fn class_string() {
|
||||||
let result = html! { h1 ."pinkie-123" { "Pinkie Pie" } };
|
let result = html! { h1."pinkie-123" { "Pinkie Pie" } };
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.into_string(),
|
result.into_string(),
|
||||||
r#"<h1 class="pinkie-123">Pinkie Pie</h1>"#
|
r#"<h1 class="pinkie-123">Pinkie Pie</h1>"#
|
||||||
|
@ -235,7 +235,7 @@ fn class_string() {
|
||||||
#[test]
|
#[test]
|
||||||
fn toggle_classes() {
|
fn toggle_classes() {
|
||||||
fn test(is_cupcake: bool, is_muffin: bool) -> Markup {
|
fn test(is_cupcake: bool, is_muffin: bool) -> Markup {
|
||||||
html!(p .cupcake[is_cupcake] .muffin[is_muffin] { "Testing!" })
|
html!(p.cupcake[is_cupcake].muffin[is_muffin] { "Testing!" })
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
test(true, true).into_string(),
|
test(true, true).into_string(),
|
||||||
|
@ -260,7 +260,7 @@ fn toggle_classes_braces() {
|
||||||
struct Maud {
|
struct Maud {
|
||||||
rocks: bool,
|
rocks: bool,
|
||||||
}
|
}
|
||||||
let result = html! { p .rocks[Maud { rocks: true }.rocks] { "Awesome!" } };
|
let result = html! { p.rocks[Maud { rocks: true }.rocks] { "Awesome!" } };
|
||||||
assert_eq!(result.into_string(), r#"<p class="rocks">Awesome!</p>"#);
|
assert_eq!(result.into_string(), r#"<p class="rocks">Awesome!</p>"#);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,14 +268,14 @@ fn toggle_classes_braces() {
|
||||||
fn toggle_classes_string() {
|
fn toggle_classes_string() {
|
||||||
let is_cupcake = true;
|
let is_cupcake = true;
|
||||||
let is_muffin = false;
|
let is_muffin = false;
|
||||||
let result = html! { p ."cupcake"[is_cupcake] ."is_muffin"[is_muffin] { "Testing!" } };
|
let result = html! { p."cupcake"[is_cupcake]."is_muffin"[is_muffin] { "Testing!" } };
|
||||||
assert_eq!(result.into_string(), r#"<p class="cupcake">Testing!</p>"#);
|
assert_eq!(result.into_string(), r#"<p class="cupcake">Testing!</p>"#);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn mixed_classes() {
|
fn mixed_classes() {
|
||||||
fn test(is_muffin: bool) -> Markup {
|
fn test(is_muffin: bool) -> Markup {
|
||||||
html!(p .cupcake .muffin[is_muffin] .lamington { "Testing!" })
|
html!(p.cupcake.muffin[is_muffin].lamington { "Testing!" })
|
||||||
}
|
}
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
test(true).into_string(),
|
test(true).into_string(),
|
||||||
|
@ -307,7 +307,7 @@ fn id_string() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn classes_attrs_ids_mixed_up() {
|
fn classes_attrs_ids_mixed_up() {
|
||||||
let result = html! { p { "Hi, " span .name .here lang="en" #thing { "Lyra" } "!" } };
|
let result = html! { p { "Hi, " span.name.here lang="en" #thing { "Lyra" } "!" } };
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.into_string(),
|
result.into_string(),
|
||||||
r#"<p>Hi, <span class="name here" id="thing" lang="en">Lyra</span>!</p>"#
|
r#"<p>Hi, <span class="name here" id="thing" lang="en">Lyra</span>!</p>"#
|
||||||
|
|
|
@ -40,14 +40,14 @@ fn attributes() {
|
||||||
#[test]
|
#[test]
|
||||||
fn class_shorthand() {
|
fn class_shorthand() {
|
||||||
let pinkie_class = "pinkie";
|
let pinkie_class = "pinkie";
|
||||||
let result = html! { p .(pinkie_class) { "Fun!" } };
|
let result = html! { p.(pinkie_class) { "Fun!" } };
|
||||||
assert_eq!(result.into_string(), r#"<p class="pinkie">Fun!</p>"#);
|
assert_eq!(result.into_string(), r#"<p class="pinkie">Fun!</p>"#);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn class_shorthand_block() {
|
fn class_shorthand_block() {
|
||||||
let class_prefix = "pinkie-";
|
let class_prefix = "pinkie-";
|
||||||
let result = html! { p .{ (class_prefix) "123" } { "Fun!" } };
|
let result = html! { p.{ (class_prefix) "123" } { "Fun!" } };
|
||||||
assert_eq!(result.into_string(), r#"<p class="pinkie-123">Fun!</p>"#);
|
assert_eq!(result.into_string(), r#"<p class="pinkie-123">Fun!</p>"#);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue