hotosm / hotosm-website

The website of the Humanitarian OpenStreetMap Team. See instructions below for writing blog posts or updating your profile.
https://www.hotosm.org
65 stars 99 forks source link

Handling empty array items in front matter #396

Open ramyaragupathy opened 5 years ago

ramyaragupathy commented 5 years ago

Noticed an extra comma character in one of our news preview. image

Further investigaiton shows an empty list item in the blog post. image

Empty list items results in additional separators.

image

image

Per our logic we add a separator for each item in the list till we reach the last element in the array. I tried a workaround to add a conditional check on next item value. However array index is accessible only by number in liquid and variables don't work in the place for index.

{% assign index = forloop.index | plus: 1 %}
{{ post.Country[index] }}
{{ post.Country[0] }}

{{ post.Country[index] }} doesn't return anything. May be there's a better way to do this? @hotosm/tech - any pointers here?

@smit1678 - How do you think we should handle this?

bismitaguha commented 5 years ago

I would like to work on this @ramyaragupathy

bismitaguha commented 5 years ago

@ramyaragupathy I found similar problems at other places also. I am working on this issue. Screenshot from 2019-03-24 19-44-44