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

https://github.com/numasi/htmx-jsx-template

HTMX extension for rendering (precompiled) JSX templates for a JSON response
https://github.com/numasi/htmx-jsx-template

bun htmx htmx-extension htmx-template jsx jsx-templates kitajs

Last synced: about 2 months ago
JSON representation

HTMX extension for rendering (precompiled) JSX templates for a JSON response

Awesome Lists containing this project

README

          

### HTMX extension for rendering (preprocessed) JSX templates from JSON responses

## Use

First you need your JSX components transpiled and bundled at `dist/templates.js`. Check out my example repo on how to get it done [here](https://github.com/numasi/htmx-jsx-json-example/)

Using it by side with [htmx-json-attribute](htps://github.com/numasi/htmx-json-attribute), one can do this:

```


```

## How it works

It depends on JSX components transpiled with kita-js HTML string generation funcition in place of React's classic createElement. The extension looks for this bundle at file `dist/template.js`, importing all the components from there upon initaliazation, and serve them upon a response by matching component function name to `hx-template` attribute (defined by the extension), passing the parsed JSON response as parameter.

## TODO

- Option to change template directory
- More build options (using ESBuild for auto-aggregation)
- Experimenting with on-the-fly (client-side) transpile
- Dynamic template imports (on need)
- Error handling
- Tests