I have express application, and EJS as view engine. I am trying to set some html to div in 2 different ways:
const attachmentFileNames = '<%= eco.attachmentFileName %>';
if (attachmentFileNames) {
$("#attachmentFileNameList").html(attachmentFileNames.replace(',', '<br/>'));
}
and
const attachmentFileNames = "<%= eco.attachmentFileName ? eco.attachmentFileName.replace(',', '<br/>') : '' %>";
if (attachmentFileNames) {
$("#attachmentFileNameList").html(attachmentFileNames);
}
The thing is that first peace of code is working as expected ('< br/>' is treated as line terminator), but the second one just sets all data as a text ('< br/>' is displayed as string).
Could anybody please explain that?