hotosm-website icon indicating copy to clipboard operation
hotosm-website copied to clipboard

Handling empty array items in front matter

Open ramyaragupathy opened this issue 6 years ago • 2 comments

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?

  • through our web page ? or
  • enable additional conditions within siteleaf template? or
  • enable CI with additional tests?

ramyaragupathy avatar Jan 16 '19 11:01 ramyaragupathy

I would like to work on this @ramyaragupathy

bismitaguha avatar Mar 16 '19 04:03 bismitaguha

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

bismitaguha avatar Mar 24 '19 14:03 bismitaguha