The discussion revolves around enhancing Discourse’s widget system to allow using .hbs files as templates instead of inline hbs code in the createWidget function. fzngagan proposes this for simplicity and better maintainability, citing a recent commit enabling hbs-style templates. sam agrees it’s reasonable and asks eviltrout for input. eviltrout explains that standard .hbs files can’t be used directly because they compile to Glimmer’s intermediate format, whereas widget hbs compiles to virtual DOM. He suggests a new extension like .widget.hbs as a possible solution, but notes that keeping widget templates inline is often more practical unless a compelling use case emerges. Separately, merefield asks whether template helpers (e.g., {{border-color c .color}}) are supported when passed via the template field — indicating they’re currently not working as expected. The thread remains open for further examples or refinements to justify the proposed .widget.hbs extension.
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?
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.