Frag is a HTML template system for Cloudflare Workers

TODO example

What does it do?

Frag takes a collection of named HTML strings (fragments) along with arbitrary data as input and produces a HTML string as output. You can annotate input HTML with special attributes that control how the data is used to produce the desired HTML output.

If you're familiar with other templating systems, I see Frag as a mix of the attribute based, natural templates seen in Thymeleaf and the logic-less, data-driven approach of Mustache.

Why do this when JSX exists?

Don't agree? All good, ignore this and use JSX.

How does it work? Why Cloudflare only?

HTMLRewriter

Is it production ready?

Probably not. Will there be bugs? Absolutely.

How to use it?

See @mrmcc3/frag on JSR for installation instructions and API docs.

Below are examples that showcase how Frag attributes behave with input data.

This website serves as an example cloudflare pages project.

TODO showcase attributes