# Conditionally rendering a plugin outlet

**URL:** <https://meta.discourse.org/t/conditionally-rendering-a-plugin-outlet/53838>\
**Category:** Development\
**Created:** [6. Dezember 2016 um 06:14 UTC](https://meta.discourse.org/t/conditionally-rendering-a-plugin-outlet/53838 "2016-12-06T06:14:50Z")\
**Posts on this page:** 1\
**Showing post:** 1

<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:** [6. Dezember 2016 um 06:14 UTC](https://meta.discourse.org/t/conditionally-rendering-a-plugin-outlet/53838/1 "2016-12-06T06:14:50Z")

</div>

I would like to introduce a mechanism for conditionally rendering outlets, I think for the time being even an unbound solution will go a reasonable distance.

The problem:

I am looking at adding a “solutions” tab to the summary page.

 ![](https://global.discourse-cdn.com/meta/original/3X/2/5/25b4ea949c92a3f2e22395ac3722f417a28139e2.png)

I can easily add it by creating a plugin outlet in the UL per:

```plaintext
<ul>
   <li>...</li>
   {{plugin-outlet "users-stats" tagName="li"}}
</ul>

```

However

- I don’t want to display anything if the solution count is 0

- I need to push up a class `linked-stat` CSS class to the enclosing LI.

My suggestion:

We currently define the behavior in

```plaintext
discourse-solved/assets/javascript/discourse/connectors/users-stats/some_file.hbs

{{#link-to 'userActivity.solved'}}
  {{user-stat value=model.solved_count label="solved.solution_summary"}}
{{/link-to}}

```

I would like to add support for:

```plaintext
discourse-solved/assets/javascript/discourse/connectors/users-stats/some_file.js.es6

export default {
    shouldRender: function() {
        return this.get("model.solved_count") > 0;
    },
    classes: function() {
        return "linked-stat";
    }
};

```

@eviltrout what are your thoughts on this, clearly getting full binding here is going to be much trickier, but for unbound decisions this seems pretty straight forward.

Thoughts?

See also

[Allow registrations of components as plugin outlets](https://meta.discourse.org/t/allow-registrations-of-components-as-plugin-outlets/53464) which is a far heavier suggestion.

---

_[View the full topic](https://meta.discourse.org/t/conditionally-rendering-a-plugin-outlet/53838)._
