Creating HTML tags for a table cell

I'm getting data for a single field in a table and I'd like to format the string with HTML. I'm getting an error that my JS syntax is incorrect but I think it looks ok.

{{
var HTMLtext = '';
var contacts = 'test@test.com Test 1, test2@test.com test 2';
var contactsArray = contacts.split(',');

contactsArray.forEach(convertMailTo);
return HTMLtext;

function convertMailTo(items, index) {
const contactArray = items.split(' ');

HTMLtext += index + ': <a href=mailto:' + contactArray[0] + '>'+ contactArray[1] + ' '+ contactArray[2] +'
';
}
}}

What am I doing wrong?

Hi @tcobrock!

You can't declare a variable or function inside of a table mapper. Does the contacts value come from within the table?

If so, you may be able to use preloaded javascript to pass the contacts data into your function:

1 Like

Yes, this worked perfectly. Thank you!

1 Like