使用 hbs 文件作为小部件的模板

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?

我认为在那里允许接受原始的 hbs 名称是一个合理的想法。@eviltrout 你怎么看?

在这种情况下,我们无法使用 hbs,因为 widgets 内部的 hbs 编译器会将其编译为虚拟 DOM,而 .hbs 的编译器使用的是 Glimmer 的中间格式。

我们可以创建另一个扩展名,例如 .widget.hbs 或类似的名称,这样就能实现该功能。

不过,大多数情况下,将 widget 代码保留在 widget 本身中是更合理的做法。我需要看到一个有说服力的示例才能确定。

相关:

这支持辅助函数吗?例如:

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

因为如果作为模板的一部分提供,我无法使其正常工作。