Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing EJS variable with string quotes

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?

like image 517
Filipe Ferminiano Avatar asked Oct 21 '25 08:10

Filipe Ferminiano


1 Answers

If you want to "unescaped" value, change <%= to <%- , for eg:

<%- price_labels %>
like image 78
digit Avatar answered Oct 22 '25 23:10

digit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!