Skip to content

Commit f1c8a53

Browse files
committed
add style attribute
fix #18
1 parent 8b0842b commit f1c8a53

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
* `attr::style`
13+
1014

1115
## [1.5.0] - 2024-12-16
1216

src/attr.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ pub fn height_int(value: i32) -> Attribute {
141141
Attribute::new_int("height", value)
142142
}
143143

144+
/// `style` attribute
145+
pub fn style(value: impl Into<Cow<'static, str>>) -> Attribute {
146+
Attribute::new("style", value)
147+
}
148+
144149
/// `cols` attribute
145150
pub fn cols(value: i32) -> Attribute {
146151
Attribute::new_int("cols", value)

tests/render_spec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ fn should_render_html_document() {
9999
#[case(attr::placeholder("hello"), "placeholder=\"hello\"")]
100100
#[case(attr::rows(10), "rows=\"10\"")]
101101
#[case(attr::cols(10), "cols=\"10\"")]
102+
#[case(attr::style("width: 5px"), "style=\"width: 5px\"")]
102103
fn should_render_attribute(#[case] attr: Attribute, #[case] expected: &str) {
103104
assert_eq!(attr.to_string(), expected);
104105
}

0 commit comments

Comments
 (0)