Skip to content

A declarative HTML rendering library that is definitely not JSX.

License

Notifications You must be signed in to change notification settings

fennifith/declarativ

Repository files navigation

Declarativ Build Status NPM Package Discord Liberapay

"Declarativ" is a lightweight and asynchronous HTML templating library for JavaScript. It definitely isn't my own reinvention of React's JSX. Okay, it kind of is, but whatever, it's still cool.

Declarativ allows you to write a document tree using a series of nested function calls, much like how Declarative UI works inside Flutter or in Jetpack Compose. Here's an example:

container(
  jumbotron(
    h1("This is a big header."),
    button("Do something").on("click", () => alert("Hello!")),
    p($.get("https://loripsum.net/api/plaintext"))
  )
)

Installation

Script Tag

<script type="text/javascript" src="https://unpkg.com/declara