I'm trying to send an array from my backend in node to the frontend with EJS files.
thisis the array in backend:
[ '2017-12-06T13:45:00.000Z',
'2017-12-06T13:50:00.000Z',
'2017-12-06T13:55:00.000Z',
'2017-12-06T14:00:00.000Z',
'2017-12-06T14:05:00.000Z',
'2017-12-06T14:10:00.000Z',
'2017-12-06T14:15:00.000Z' ]
but when I print in EJS file like this:
<%= price_labels %>
I get this in rendered HTML:
[2017-12-06T13:45:00.000Z,2017-12-06T13:50:00.000Z,2017-12-06T13:55:00.000Z,2017-12-06T14:00:00.000Z,2017-12-06T14:05:00.000Z,2017-12-06T14:10:00.000Z,2017-12-06T14:15:00.000Z]
without string quotes. How can I get the string quotes?
If you want to "unescaped" value, change <%= to <%- , for eg:
<%- price_labels %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With