thoughts on extensible custom tags
See original GitHub issueSo 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`<button>my ${opts.name} button</button>`
}
const Col = function (_yield, opts) {
return bel`<div class="column">${_yield}</div>`
}
const customtagsuse = bel`<div><Button name="Nick" /></div>`
// which is actually just
const customtagsuse = bel`<div>${Button({name: "Nick"})}</div>`
// or
const customtagsuse2 = bel`<div><Col> some cols </Col></div>`
// which is actually
const customtagsuse2 = bel`<div>${Col(" some cols ")}</div>`
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?
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
U.S. GAAP – XBRL Custom Tags Trend - SEC.gov
“From 2019 to 2020, custom tag rates changed from 16% to 20%. The analysis for Forms 10-K and 10-K/A shows a decrease in...
Read more >Defining custom tags using hiccup ? - Google Groups
Hi, I like the way hiccup allows you to represent html elements as datastructure. However this is limited to native elements.
Read more >An extensible ExifReader class with customizable tag handlers
An ExifReader class in C# that supports custom formatting and extraction. StyleCop compliant code, with demos for WPF and Windows Forms.
Read more >How to create customizable Liquid tags in Jekyll - sverrirs.blog
This is the definite guide to show you how to create flexible and fully customizable Liquid code tags to use in Jekyll static...
Read more >Extensible Enumerations A Guide for Preparers - FASB
any party responsible for tagging information in an SEC Extensible Business ... Extensible Enumeration elements are a custom datatype, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@SilentCicero webpack can run browserify transforms too.
When parsing the template literal, it doesn’t know about the variables on the same scope of the literal, only the expressions passed in with
${}
. So it would require registering each component as the above examples are doing and informing the parser about that registry, which can get pretty messy.Hey guys, was thinking about this today and had a similar idea… what about using proper custom elements from the web components spec?
EDIT: Probably no matter what you do, the issue of passing in attributes other than strings will be annoying, ie.
<MyElement codes=${ [ 'foo', 'bar' ] }></MyElement>
EDIT2: Threw together an example using choo