An open API service indexing awesome lists of open source software.

https://github.com/tamschi/lignin

VDOM in Rust
https://github.com/tamschi/lignin

Last synced: about 2 months ago
JSON representation

VDOM in Rust

Awesome Lists containing this project

README

        

# lignin

[![Lib.rs](https://img.shields.io/badge/Lib.rs-*-84f)](https://lib.rs/crates/lignin)
[![Crates.io](https://img.shields.io/crates/v/lignin)](https://crates.io/crates/lignin)
[![Docs.rs](https://docs.rs/lignin/badge.svg)](https://docs.rs/lignin)

![Rust 1.54](https://img.shields.io/static/v1?logo=Rust&label=&message=1.54&color=grey)
[![CI](https://github.com/Tamschi/lignin/workflows/CI/badge.svg?branch=develop)](https://github.com/Tamschi/lignin/actions?query=workflow%3ACI+branch%3Adevelop)
![Crates.io - License](https://img.shields.io/crates/l/lignin/0.1.0)

[![GitHub](https://img.shields.io/static/v1?logo=GitHub&label=&message=%20&color=grey)](https://github.com/Tamschi/lignin)
[![open issues](https://img.shields.io/github/issues-raw/Tamschi/lignin)](https://github.com/Tamschi/lignin/issues)
[![open pull requests](https://img.shields.io/github/issues-pr-raw/Tamschi/lignin)](https://github.com/Tamschi/lignin/pulls)
[![good first issues](https://img.shields.io/github/issues-raw/Tamschi/lignin/good%20first%20issue?label=good+first+issues)](https://github.com/Tamschi/lignin/contribute)

[![crev reviews](https://web.crev.dev/rust-reviews/badge/crev_count/lignin.svg)](https://web.crev.dev/rust-reviews/crate/lignin/)
[![Zulip Chat](https://img.shields.io/endpoint?label=chat&url=https%3A%2F%2Fiteration-square-automation.schichler.dev%2F.netlify%2Ffunctions%2Fstream_subscribers_shield%3Fstream%3Dproject%252Flignin)](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.