choojs / choojs/nanohtml

thoughts on extensible custom tags

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

Description

So this may not be in the philosophy of bel, but how/should/can I easily create an extensible module for bel/yoyo (the module I use) that allows for custom tags/props that just render functions.

Here is what I'm thinking:

```
const Button = function (opts) {
return bel`my ${opts.name} button`
}

const Col = function (_yield, opts) {
return bel`

${_yield}
`
}

const customtagsuse = bel`

`

// which is actually just

const customtagsuse = bel`

${Button({name: "Nick"})}
`

// or

const customtagsuse2 = bel`

some cols
`

// which is actually

const customtagsuse2 = bel`

${Col(" some cols ")}
`
```

Kinda reactish, but all it's doing is regexing the string, and replacing it with the element.

I'm thinking of providing a layer to bel.

so something like:

```
var extensible = require("bel-custom")
var bel = extensible(require("bel))
bel.customElements = {"Button": Button}; // sort of thing
```

Any thoughts on design patterns, approaches, potential pitfalls, potential benefits @shama?

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.