Jekyll: check if email content was empty

I have a series of posts in a Jekyll project where some of them have only a title and some have a title and content. I want to do different things from the post in each case. For instance:

{% for post in site.categories.publications %} {{ post.title }} {% if post.content == "" or post.content == nil or post.content == blank %} <p>Nothing here.</p> {% else %} {{ post.content }} {% endif %} {% endfor %} 

But the if does not actually catch empty messages. I based my terms on this page , but none of the three possibilities caught empty messages. Any ideas on how to handle these posts?

+6
source share
1 answer

Make sure you have nothing after the front case

 --- --- NO NEW LINE HERE !! 

No place, no new line

Sometimes a text editor adds a new line at the end of a file. You can get rid of this:

 {% assign content = post.content | strip_newlines %} 

and then check:

 {% if content == "" %} 
+7
source

Source: https://habr.com/ru/post/979201/


All Articles