Basically, the code will loop through the database for posts, but it will only post if the scheduled date is less than or equal to the current date. It searches through the bank for all posts and lists, but the ones that are scheduled, it will not show. And when there are no scheduled posts or there is nothing in the bank, it says it has no posts.
There are two elses. Hence the question: Is there just one?
I have tried in many ways and I can not. An else is for when there is nothing in the bank, the other for when there are no scheduled posts. One else does not recognize the other. I would like an else only.
<div class="container">
<% var valor = "No posts!"; %>
<% if(noticias.length > 0) { %>
<% for(var i = 0; i < noticias.length; i++) { %>
<% if(noticias[i].publicacao_agendada <= moment(new Date()).format('YYYY-MM-DD[T]H:mm')) { %>
<div class="row">
<div class="col-md-12">
<div class="noticia_wrapper">
<%= noticias[i].publicacao_agendada %>
<span class="noticia_autor"><%=noticias[i].autor%></span>
<a href="noticia?id_noticia=<%= noticias[i].id_noticia %>" class="noticia_titulo"><%=noticias[i].titulo%></a>
<span class="noticia_data"><%= moment(noticias[i].data_noticia).format(data) %></span>
<br />
<p class="noticia_resumo">
<%=noticias[i].noticia%>
</p>
</div>
</div>
</div>
<% } else { %>
<h1><%= valor %></h1>
<% } %>
<% } %>
<% } else { %>
<h1><%= valor %></h1>
<% } %>
</div>
To facilitate understanding, I, @LeoCaracciolo, put something simpler
if(noticias.length > 0) {
for(var i = 0; i < noticias.length; i++) {
if(noticias[i].publicacao_agendada <= moment(new Date()).format('YYYY-MM-DD[T]H:mm')) {
} else {
}
}
} else {
}