hotosm-website
hotosm-website copied to clipboard
Handling empty array items in front matter
Noticed an extra comma character in one of our news preview.
Further investigaiton shows an empty list item in the blog post.
Empty list items results in additional separators.
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?
I would like to work on this @ramyaragupathy
@ramyaragupathy I found similar problems at other places also. I am working on this issue.