diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e28005..683c0e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/attr.rs b/src/attr.rs index a12ce95..994580e 100644 --- a/src/attr.rs +++ b/src/attr.rs @@ -141,6 +141,11 @@ pub fn height_int(value: i32) -> Attribute { Attribute::new_int("height", value) } +/// `style` attribute +pub fn style(value: impl Into>) -> Attribute { + Attribute::new("style", value) +} + /// `cols` attribute pub fn cols(value: i32) -> Attribute { Attribute::new_int("cols", value) diff --git a/tests/render_spec.rs b/tests/render_spec.rs index d8b1105..fdcbfcc 100644 --- a/tests/render_spec.rs +++ b/tests/render_spec.rs @@ -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); }