Using a hbs file as the template for widget

As this commit makes it possible to use hbs style code as a widget template, and that being a simpler and better way of doing things than generating HTML using the hyper script object.

I was thinking if it is possible(or would it be cool as a proposal) to be able to pass a .hbs file as a parameter to createWidget function’s template field instead of writing the template code there itself?

2 Likes

I think its a reasonable idea to allow it to accept a raw hbs name there. @eviltrout what are your thoughts?

1 Like

We can’t use hbs in this case because the hbs compiler inside widgets compiles down to virtual dom and the compiler for .hbs uses glimmer’s intermediate format.

We could create another extension .widget.hbs or similar and that could do it.

I think most of the time though it makes sense to keep the widget code in the widget itself. I’d have to see a convincing example.

4 Likes

Related:

Does this support helpers?, e.g.:

    <td style={{border-color c.color}}>

Because I can’t get that to work if supplied as part of the template.

1 Like