H
H
HoHsi2015-11-02 07:26:02
Node.js
HoHsi, 2015-11-02 07:26:02

How to get rid of extra padding in EJS?

Good morning!
How to get rid of extra new lines in the EJS template engine, I will immediately say that I use the master version 2.3.4, yes I tried -%>, yes I tried <%_ _%>.
Actually the code itself:

<%

var names = ["a", "b", "c"]

%><% names.forEach(function (name) { -%>
name: <%= name %>
<% }) -%>

And what do we have:
name: a

name: b

name: c

but want:
name: a
name: b
name: c

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
HoHsi, 2015-11-02
@HoHsi

Found problem
579 linelib/ejs.js

line = line.replace('\n', '');
self.truncate = false;

need to add:
line = line.replace('\r\n', '');
line = line.replace('\n', '');
self.truncate = false;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question