Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/marcoroth/stimulus-render

[PoC] HTML rendering mechanism for Stimulus Controllers
https://github.com/marcoroth/stimulus-render

dom html javascript jsx stimulus typescript

Last synced: 18 days ago
JSON representation

[PoC] HTML rendering mechanism for Stimulus Controllers

Awesome Lists containing this project

README

        

# Stimulus Render

## Getting Started

```bash
yarn add stimulus-render
```

### Counter Example

```html


```

```js
// app/javascript/controllers/counter_controller.js

import { Controller } from '@hotwired/stimulus'
import { useRender, h } from 'stimulus-render'

/** @jsx h */

export default class extends Controller {
static values = { counter: 1 }

connect () {
useRender(this)
}

increment () {
this.counterValue += 1
}

render () {
return (



Count: {this.counterValue}


)
}
}
```

### List/Item Example

```html








```

```js
// app/javascript/controllers/list_controller.js

import { Controller } from '@hotwired/stimulus'
import { useRender, h } from 'stimulus-render'
import { processMarkdown } from 'some-markdown-rendering-package'

/** @jsx h */

export default class extends Controller {
static targets = ['item']

connect () {
useRender(this)
}

renderItemTarget(target) {
return (

{processMarkdown(target.dataset.value)}

)
}
}
```