How to print Watchers of an Issue?

In this guide, we will show you how to print the Watchers of an Issue using our Reporter plugin.

Code examples

We got an issue with 3 watchers added to it.

issue_3_watchers.png

We could print them in a short way. Just in a row one after another, separated with a comma. The following code is used.

{{ issue.watchers.all | map: 'name' | join: ', ' }}

And the result is this one.

short_list.png

Also, we will provide one more example with a bit more information added for the watchers. They will be listed with the ID of the user, first name, last name, full name, and email. This code is used.

{% for watcher in issue.watchers %}
  <p>
    <span>{{ watcher.id }}, </span>
    <span>{{ watcher.name }}, </span>
    <span>{{ watcher.firstname }}, </span>
    <span>{{ watcher.lastname }}, </span>
    <span>{{ watcher.mail }}</span>
  </p>
{% endfor %}

As a result, you will have this list.

long_list.png

Video demonstration

Was this article helpful? Yes  No
351 from 378 found this helpful