Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra new lines added #43

Closed
ghost opened this issue Mar 7, 2012 · 11 comments
Closed

Extra new lines added #43

ghost opened this issue Mar 7, 2012 · 11 comments

Comments

@ghost
Copy link

ghost commented Mar 7, 2012

I have a template:

A list of famous people:
<% names.forEach(function (name) { %>
name: <%= name %>
<% } %>

Which generates:

A list of famous people:

name: Alexander

name: Bruce

name: Ceasar

name: David

Could the new lines be removed?

@ghost
Copy link

ghost commented Mar 30, 2012

In the newest version of EJS there is the -%> tag ... So changing you code to the below should fix the issue.

A list of famous people:
<% names.forEach(function (name) { -%>
name: <%= name %>
<% } -%>

@ForbesLindesay
Copy link
Contributor

This is resolved and can be closed @visionmedia

@tj tj closed this as completed Sep 18, 2012
@IonicaBizau
Copy link

@ForbesLindesay I still have the same problem:

<% var fruits = ["Apple", "Pear", "Orage", "Lemon"] %>
<ul>
   <% for(var i = 0; i < fruits.length; ++i) {%>
        <li><%=fruits[i]%></li>
   <% } %>
</ul>

Renders:

<ul>

        <li>Apple</li>

        <li>Pear</li>

        <li>Orage</li>

        <li>Lemon</li>

</ul>

How can I prevent the empty lines?

@IonicaBizau
Copy link

Also, I just posted this question: http://stackoverflow.com/q/36175454/1420197

@tj
Copy link
Owner

tj commented Mar 23, 2016

@IonicaBizau: Newline slurping with <% code -%> or <% -%> or <%= code -%> or <%- code -%> the hyphen in -%> should do the trick

@IonicaBizau
Copy link

@tj Oh, right! 👍 Is there a place where these are documented?

@mde
Copy link
Collaborator

mde commented Mar 24, 2016

FWIW, this version of EJS isn't maintained anymore. The current one (with additional whitespace modes) is here: https://github.com/mde/ejs

@IonicaBizau
Copy link

@mde Oh, nice! 👍 Seems like what I was searching is here. Thanks a lot! 😁

@mde
Copy link
Collaborator

mde commented Mar 24, 2016

👍

1 similar comment
@taozhi8833998
Copy link

👍

@joaopedrodcf
Copy link

This solved my issue as well 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants