# api.decorateWidget - hoe kan ik de namen van de templates vinden?

**URL:** https://meta.discourse.org/t/api-decoratewidget-how-can-i-find-the-templates-names/172907
**Category:** Support
**Created:** [10 december 2020 om 18:09 UTC](https://meta.discourse.org/t/api-decoratewidget-how-can-i-find-the-templates-names/172907 "2020-12-10T18:09:21Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [10 december 2020 om 20:31 UTC](https://meta.discourse.org/t/api-decoratewidget-how-can-i-find-the-templates-names/172907/4 "2020-12-10T20:31:10Z")

</div>

You aren’t going to be able to use `decorateWidget()` on a plugin outlet. Try something like this:

```plaintext
<script type="text/discourse-plugin" version="0.8.42">
    const h = require("virtual-dom").h;
    api.createWidget("user-card-custom-field", {
      html(attrs) {
        const userCustomFields = attrs.user.custom_fields;
        if (userCustomFields.user_field_4) {
            return h('span.poster-user-field', userCustomFields.user_field_4);
        }
      }
    });
</script>

<script type="text/x-handlebars" data-template-name="/connectors/user-card-post-names/user-card-custom-field">
    {{mount-widget widget="user-card-custom-field" args=(hash user=user)}}
</script>

```

The `mount-widget` is passing the user object we have available from the plugin outlet in core and making it available in the attributes of the `user-card-custom-field` widget we’ve created.

> <https://github.com/discourse/discourse/blob/aa0d4ea764959bd7ec5127f78dbec68de4dc8337/app/assets/javascripts/discourse/app/templates/components/user-card-contents.hbs#L68-L68>

Make sure you’ve added `user_field_4` to your `public user custom fields` or `staff user custom fields` site settings as needed.

## Edit

Also, unless there’s anything particularly special you need to do, you should be able to avoid widgets altogether and just use the plugin outlet:

```plaintext
<script type="text/x-handlebars" data-template-name="/connectors/user-card-post-names/user-card-custom-field">
  {{#if user.custom_fields.user_field_1}}
    <span class="poster-user-field">{{user.custom_fields.user_field_1}}</span>
  {{/if}}
</script>

```

---

_[View the full topic](https://meta.discourse.org/t/api-decoratewidget-how-can-i-find-the-templates-names/172907)._
