https://github.com/tamschi/lignin
VDOM in Rust
https://github.com/tamschi/lignin
Last synced: about 2 months ago
JSON representation
VDOM in Rust
- Host: GitHub
- URL: https://github.com/tamschi/lignin
- Owner: Tamschi
- License: other
- Created: 2020-10-02T11:27:05.000Z (over 4 years ago)
- Default Branch: develop
- Last Pushed: 2024-10-23T17:02:57.000Z (8 months ago)
- Last Synced: 2024-10-31T11:51:44.809Z (8 months ago)
- Language: Rust
- Size: 1.69 MB
- Stars: 9
- Watchers: 5
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# lignin
[](https://lib.rs/crates/lignin)
[](https://crates.io/crates/lignin)
[](https://docs.rs/lignin)
[](https://github.com/Tamschi/lignin/actions?query=workflow%3ACI+branch%3Adevelop)
[](https://github.com/Tamschi/lignin)
[](https://github.com/Tamschi/lignin/issues)
[](https://github.com/Tamschi/lignin/pulls)
[](https://github.com/Tamschi/lignin/contribute)[](https://web.crev.dev/rust-reviews/crate/lignin/)
[](https://iteration-square.schichler.dev/#narrow/stream/project.2Flignin)A lightweight but featureful virtual DOM library, primarily for web use.
`no_std` and no dependencies without the `"callbacks"` feature.
## Installation
Please use [cargo-edit](https://crates.io/crates/cargo-edit) to always add the latest version of this library:
```cmd
cargo add lignin && cargo add -D lignin --features callbacks
```Some type constraints are more strict with the `"callbacks"` feature enabled, so make sure to always check this way!
**When writing a renderer that supports callbacks**, instead use
```cmd
cargo add lignin --features callbacks
```to always enable the feature.
## Features
### `"callbacks"`
Enables DOM callback support. Off by default. Requires `std`.
Apps or components can be written against the callback API without enabling this feature, in which case those code paths can be erased at compile-time.
## Example
```rust
use lignin::{Node, Element, ElementCreationOptions};// Please bring your own allocator where necessary.
let _ = &Node::HtmlElement {
element: &Element {
name: "DIV", // Use all-caps for more efficient DOM interactions.¹
creation_options: ElementCreationOptions::new(), // `const fn` builder and getter/setter patterns for extensible interfaces.
attributes: &[],
content: Node::Multi(&[
"Hello! ".into(), // Some convenience included.
Node::Comment {
comment: "--> Be mindful of HTML pitfalls.