choojs / choojs/nanohtml

Support custom components

Open
#79 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
688
Forks
48
PR merge metrics
No merged PRs in 30d

Description

First of all, I want to know if this makes sense to you, I have more doubts than answer but here are my thoughs. Basically, allow to write this code (taking the list example from readme):

```js
// ...
function render (selected) {
return bel`


Selected: ${selected}


${list(bears, onselected)}
`
}
// ...
```

like this

```js
// ...
function render (selected) {
return bel`


Selected: ${selected}




`
}
// ...
```

Implementation shouldn't be so hard, unless I'm missing something, it would need a registration method for components, and when evaluating tags, if the tag is a registered component, use the registered function for that component. The benefit I see here is for frameworks/libraries depending on bel in supporting components, like in [choo ](https://github.com/yoshuawuyts/choo/issues/486#issuecomment-300143602). and also the similarity with other component based libraries like React and Vue. Now my doubt is if those benefit are enough for changing bel. Also, this change wouldn't be a breaking change, just a minor release.

Any thoughts about it? Am I talking nonsense? :speak_no_evil:

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.