# How to have if "string === string" in template?

**URL:** <https://meta.discourse.org/t/how-to-have-if-string-string-in-template/158404>\
**Category:** Development\
**Created:** [July 21, 2020, 4:11pm UTC](https://meta.discourse.org/t/how-to-have-if-string-string-in-template/158404 "2020-07-21T16:11:34Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![JQ331](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@JQ331](https://meta.discourse.org/u/JQ331)\
**Post date:** [July 22, 2020, 10:38pm UTC](https://meta.discourse.org/t/how-to-have-if-string-string-in-template/158404/5 "2020-07-22T22:38:45Z")

</div>

Thanks for this–it helps clarify a lot.

Haven’t quite gotten it to work yet–in part bc I’m not finding examples out there of using computed properties to do this kind of operation.

> [@justin](#):
>
> So say you have a template under `templates/components/my-component.hbs` . You’d have to use the JS file `components/my-component.js` to do the computation.

In my case, in my plugin, I am making the change in the group index template. So in the file: `plugin/assets/javascripts/discourse/groups/index.hbs` (I just put the entire groups index code there and add changes on top of it.)

Do you mean that the computed property js would go in a file I create that is: `plugin/assets/javascripts/discourse/groups/index.js`? Or can I just put that code in an initializer?

> [@justin](#):
>
> ```plaintext
> export default Component.extend({
> @discourseComputed("string1", "string2")
> property(string1, string2) {
> return string1 === string2;
> }
> });
> 
> ```

This is my best attempt to implement what you are talking about–is this what you had in mind:

js:

```
export default Component.extend({
  @discourseComputed("group.name", "Amazing_Name")
  property(group.name, Amazing_Name) {
    return group.name === Amazing_Name
  }
})

```

hbs:

```
 {{#if property}}
    <div>Yep There is a Match!</div>
 {{/if}}

```

Or did you mean that I should literally enter general values like “string1” and “string2” in `@discourseComputed,` and then change the template to `{{#if property group.name "Amazing_Name"}}` ? (only that way could I account for each value being dynamic in the template.)

Haven’t gotten either approach to quite work yet.

Thank you for your help.

---

_[View the full topic](https://meta.discourse.org/t/how-to-have-if-string-string-in-template/158404)._
