# Using a hbs file as the template for widget

**URL:** https://meta.discourse.org/t/using-a-hbs-file-as-the-template-for-widget/121420
**Category:** Development
**Created:** [June 26, 2019, 6:14pm UTC](https://meta.discourse.org/t/using-a-hbs-file-as-the-template-for-widget/121420 "2019-06-26T18:14:49Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [June 26, 2019, 6:14pm UTC](https://meta.discourse.org/t/using-a-hbs-file-as-the-template-for-widget/121420/1 "2019-06-26T18:14:49Z")

</div>

As [this](https://github.com/discourse/discourse/commit/dffb1fc4ee8a4d58f48145decb1590a304e8cf7d) 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?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [July 1, 2019, 1:36am UTC](https://meta.discourse.org/t/using-a-hbs-file-as-the-template-for-widget/121420/2 "2019-07-01T01:36:44Z")

</div>

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

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [July 1, 2019, 2:07am UTC](https://meta.discourse.org/t/using-a-hbs-file-as-the-template-for-widget/121420/3 "2019-07-01T02:07:28Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [September 3, 2019, 11:37am UTC](https://meta.discourse.org/t/using-a-hbs-file-as-the-template-for-widget/121420/4 "2019-09-03T11:37:15Z")

</div>

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.
