Value cannot be passed from Javascript to EJS, so how can I achieve it with another way?
duruburak opened this issue · 1 comments
duruburak commented
I can't put everything inside the EJS, I need to find a way to make this happen, any help appreciated, thank you.
for (let i = 1; i < 3; i++) {
initializeSlider($(".slider-1"), [
<% let index = %> i
"data:image/<%=posts[index].images[0].image.contentType%>;base64,\
<%=posts[index].images[0].image.data.toString('base64')%>",
"data:image/<%=posts[index].images[1].image.contentType%>;base64,\
<%=posts[index].images[1].image.data.toString('base64')%>",
"data:image/<%=posts[index].images[2].image.contentType%>;base64,\
<%=posts[index].images[2].image.data.toString('base64')%>",
"data:image/<%=posts[index].images[3].image.contentType%>;base64,\
<%=posts[index].images[3].image.data.toString('base64')%>",
"data:image/<%=posts[index].images[4].image.contentType%>;base64,\
<%=posts[index].images[4].image.data.toString('base64')%>",
]);
}
duruburak commented
<% for (let i = 0; i < posts.length; i++) { %>
initializeSlider($(".slider-<%= i+1 %>"), [
"data:image/<% posts[i].images[0].image.contentType %>;base64,\
<%= posts[i].images[0].image.data.toString('base64') %>",
"data:image/<% posts[i].images[1].image.contentType %>;base64,\
<%= posts[i].images[1].image.data.toString('base64') %>",
"data:image/<% posts[i].images[2].image.contentType %>;base64,\
<%= posts[i].images[2].image.data.toString('base64') %>",
"data:image/<% posts[i].images[3].image.contentType %>;base64,\
<%= posts[i].images[3].image.data.toString('base64') %>",
"data:image/<% posts[i].images[4].image.contentType %>;base64,\
<%= posts[i].images[4].image.data.toString('base64') %>",
]);
<% } %>