Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
Printing newline characters in ejs

I'd like to print a string with newline characters with ejs.

I have this ejs file:

<div class="result">
  <%=names%>
</div>

If the string "names" is "line 1</br>line 2" it will print it literally:

line 1</br>line 2

But I'd like this:

line 1
line 2

What is the best way of getting ejs to correctly interpret newline characters?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The ejs syntax I was using is specifically for unescaped input:

<div class="result">
  <%=names%>
</div>

Simply using '-' instead of '=' gives the desired result:

<div class="result">
  <%-names%>
</div>

Which gives:

line 1
line 2

Kudos @Pavan Kumar T S

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!