Closed welblaud closed 8 years ago
remember that ejs is "like" php if you write:
<div class="categories">
<% var categories = public.articles._data[slug].categories;
if (categories !== undefined) {
for (var i = 0; i < categories.length; i++) {
if (categories[i] !== "vim tips") { %>
<span class="category"><a class="category-link" href="/<%= categories[i] %>"><%= categories[i] %></a></span>
<% } else { %>
<span class="category"><a class="category-link" href="/vim">vim tips</a></span>
<% }
}
} %>
</div>
You will get a lot of less whitespace: new lines inside of <% %> will be not send to the html
Thanks a lot, it explains everything! Solved.
welcome :smile: ! Really happy to be usefull!
I run a blog on Harp. Everything works like a charm but one thing I can’t achieve (and don’t understand). The whole project uses EJS. The problem is in the produced source (HTML) there is a lot of additional whitespace. I’ve tried to reduce it like in case of menus but that did not work.
I would expect reducing of line breaks at least. Typically I use something like this:
But the problem is in parts dynamically served by EJS, there this does not work, the code looks ugly:
Is there any way how to deal with that? If I use minified LESS, I would like to use minified (or at least reasonably looking) HTML as well!
Example code: