I have a bunch of documents stored in MongoDB like this:
{
"_id" : ObjectId("5a8706973e4306202c424122"),
"title" : "how to make a robot?",
"description" : "arif",
"createdBy" : ObjectId("5a71a0ebc252020d4c127911"),
"allLearningGoals" : "my third learning goals, my fourth learning goals",
"resources_upload" : "{\"data\":[]}",
"participants" : "[{\"email\":\"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="89fafcfbc9eee4e8e0e5a7eae6e4">[email protected]</a>\"},{\"email\":\"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3e5f4c57587e4e5c52105a5b">[email protected]</a>\"},{\"email\":\"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cca1adaf8caba1ada5a0e2afa3a1">[email protected]</a>\"}]",
"createdAt" : ISODate("2018-02-24T10:15:42.548Z"),
"__v" : 0
}
I aim to showcase each participant in a table and also utilize them for sending email notifications. The data is retrieved using mongo findById and I can view it in the console as:
console.log(data.project); // this is working fine
So in Handlebars, I can access other data like:
{{#if data.project}}
{{ data.project.title }}
{{ data.project.description}}
But when trying to display participants, the entire array is shown:
{{ data.project.participants}}
It displays as:
[{\"email\":\"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="96e5e3e4d6f1fbf7fffab8f5f9fb">[email protected]</a>\"},{\"email\":\"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="41203328270131232d6f2524">[email protected]</a>\"},{\"email\":\"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a3cec2c0e3c4cec2cacf8dc0ccce">[email protected]</a>\"}]
How can I format it to show like this:
email: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a9dadcdbe9cec4c8c0c587cac6c4">[email protected]</a>
I attempted the following:
{{#if data.project}}
<!-- added student list-->
<div class="form-group">
<div class="form-row">
<div class="col-md-12">
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Email</th>
</tr>
</thead>
<tbody>
{{#each participants}}
<tr>
<td>
{{ this }}
</td>
<td>
test
</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</div>
<!-- added student list end -->
</div>
{{/if}}
However, it's not functioning correctly... Can someone provide some suggestions? Thank you.