As of now, expressions are not supported in the LWC template.
You can achieve this by defining custom properties in the controller only.
Let's assume you have got these data from the wired method, in the wired callback you can configure that properties based on conditions.
Here I have created two custom properties(customType, accountType
) on contact js Object and put the values conditionally in those
@wire(getContactList)
wiredContacts({ error, data }) {
if (data) {
let newContacts = [];
for (let index = 0; index < data.length; index++) {
let contact = Object.assign({}, data[index]);
if(contact.Type){
if(contact.subType){
contact.customType = contact.Type + ' - ' + contact.subType;
} else {
contact.customType = contact.Type;
}
}
if(dtcontact.IsSomething__c){
contact.AccountType = 'Customer';
} else {
contact.AccountType = contact.RecordType_Name__c
}
newContacts.push(contact);
}
this.contacts = newContacts;
this.error = undefined;
} else if (error) {
this.error = error;
this.contacts = undefined;
}
}
Now as you have defined custom properties based on conditions just use those in the htmll markup.
<tbody>
<template for:each={contacts} for:item="dt" for:index="indexvar">
<tr id="datarow">
<td>{!dt.customType}</td>
<td>{!dt.accountType}</td>
</tr>
</template>
</tbody>