Skip to content

Commit

Permalink
explain the benefit of using simple rust functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jcornaz committed Nov 3, 2024
1 parent fc2f9e7 commit 8e1948c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ let greeting = h1(
assert_eq!(greeting.to_string(), r#"<h1 class="bold">Hello world!</h1>"#);
```

Because those are simple rust functions, it is easy to leverage rust features like conditions, loops and iterators:

```rust
let list = ul([], (1..=3).map(|n| li([], [n.to_string().into()])));
assert_eq!(list.to_string(), "<ul><li>1</li><li>2</li><li>3</li></ul>");
```


## MSRV

The minimum supported rust version is currently `1.60`.
Expand Down
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
//! assert_eq!(greeting.to_string(), r#"<h1 class="bold">Hello world!</h1>"#);
//! ```
//!
//! Because those are simple rust functions, it is easy to leverage rust features like conditions, loops and iterators:
//!
//! ```
//! # use fun_html::{elt::{li,ul}};
//! let list = ul([], (1..=3).map(|n| li([], [n.to_string().into()])));
//! assert_eq!(list.to_string(), "<ul><li>1</li><li>2</li><li>3</li></ul>");
//! ```
//!
//! ## Escape hatches
//!
//! If necessary, it is possible to define custom elements and attributes with respectively [`Element::new`] and [`Attribute::new`].
Expand Down

0 comments on commit 8e1948c

Please sign in to comment.