Skip to content

Commit

Permalink
add style attribute
Browse files Browse the repository at this point in the history
fix #18
  • Loading branch information
jcornaz committed Dec 21, 2024
1 parent 8b0842b commit f1c8a53
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Added

* `attr::style`


## [1.5.0] - 2024-12-16

Expand Down
5 changes: 5 additions & 0 deletions src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ pub fn height_int(value: i32) -> Attribute {
Attribute::new_int("height", value)
}

/// `style` attribute
pub fn style(value: impl Into<Cow<'static, str>>) -> Attribute {
Attribute::new("style", value)
}

/// `cols` attribute
pub fn cols(value: i32) -> Attribute {
Attribute::new_int("cols", value)
Expand Down
1 change: 1 addition & 0 deletions tests/render_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ fn should_render_html_document() {
#[case(attr::placeholder("hello"), "placeholder=\"hello\"")]
#[case(attr::rows(10), "rows=\"10\"")]
#[case(attr::cols(10), "cols=\"10\"")]
#[case(attr::style("width: 5px"), "style=\"width: 5px\"")]
fn should_render_attribute(#[case] attr: Attribute, #[case] expected: &str) {
assert_eq!(attr.to_string(), expected);
}
Expand Down

0 comments on commit f1c8a53

Please sign in to comment.