Skip to content

Commit

Permalink
rename *_utf_8 to *_utf8
Browse files Browse the repository at this point in the history
  • Loading branch information
jcornaz committed Dec 16, 2024
1 parent 8dc04bb commit c7c4d8e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Deprecated

* `attr::charset_utf_8()` and `elt::meta_charset_utf_8()`
(renamed to `attr::charset_utf8()` and `elt::meta_charset_utf8()`)

### Added

* `attr::none()` for conditional rendering of an attribute
* implement `Default` for `Element` and `Attribute`
* `attr::disabled()` and `attr::autofocus()`
* `attr::charset_utf8()` and `elt::meta_charset_utf8()`


## [1.4.0] - 2024-12-13

Expand Down
6 changes: 6 additions & 0 deletions src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,16 @@ pub fn charset(charset: impl Into<Cow<'static, str>>) -> Attribute {
}

/// Alias for `charset("UTF-8")`
#[deprecated(since = "1.5.0", note = "renamed to 'meta_charset_utf8'")]
pub fn charset_utf_8() -> Attribute {
charset("UTF-8")
}

/// Alias for `charset("UTF-8")`
pub fn charset_utf8() -> Attribute {
charset("UTF-8")
}

/// `name` attribute
pub fn name(name: impl Into<Cow<'static, str>>) -> Attribute {
Attribute::new("name", name)
Expand Down
8 changes: 7 additions & 1 deletion src/elt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,17 @@ pub fn meta(attributes: impl IntoIterator<Item = Attribute>) -> Element {
Element::new_void("meta", attributes)
}

/// `<meta name="viewport" content="width=device-width, initial-scale=1.0">`
/// `<meta charset="UFT-8">`
#[deprecated(since = "1.5.0", note = "renamed to 'meta_charset_utf8'")]
pub fn meta_charset_utf_8() -> Element {
raw("<meta charset=\"UTF-8\">")
}

/// `<meta charset="UFT-8">`
pub fn meta_charset_utf8() -> Element {
raw("<meta charset=\"UTF-8\">")
}

/// `<meta name="viewport" content="width=device-width, initial-scale=1.0">`
pub fn meta_viewport() -> Element {
raw("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">")
Expand Down
4 changes: 4 additions & 0 deletions tests/render_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ fn should_render_html_document() {
#[case(attr::target(AnchorTarget::Parent), "target=\"_parent\"")]
#[case(attr::target(AnchorTarget::Frame("myframe".into())), "target=\"myframe\"")]
#[case(attr::charset("foobar"), "charset=\"foobar\"")]
#[allow(deprecated)]
#[case(attr::charset_utf_8(), "charset=\"UTF-8\"")]
#[case(attr::charset_utf8(), "charset=\"UTF-8\"")]
#[case(attr::name("hello"), "name=\"hello\"")]
#[case(attr::content("bla"), "content=\"bla\"")]
#[case(attr::alt("bla"), "alt=\"bla\"")]
Expand Down Expand Up @@ -121,7 +123,9 @@ fn should_render_attribute(#[case] attr: Attribute, #[case] expected: &str) {
#[case(elt::script([("foo", "bar").into()], "alert('hello');"), "<script foo=\"bar\">alert('hello');</script>")]
#[case(elt::script_empty([attr::src("/foo.js")]), "<script src=\"/foo.js\"></script>")]
#[case(elt::meta([("foo", "bar").into()]), "<meta foo=\"bar\">")]
#[allow(deprecated)]
#[case(elt::meta_charset_utf_8(), "<meta charset=\"UTF-8\">")]
#[case(elt::meta_charset_utf8(), "<meta charset=\"UTF-8\">")]
#[case(
elt::meta_viewport(),
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"
Expand Down

0 comments on commit c7c4d8e

Please sign in to comment.