From e62e7bb6b14555c9bbe5d40d217103984f4f80e6 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sun, 27 Oct 2019 09:57:37 -0400 Subject: Rewrite progress --- _includes/group-by-array | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 _includes/group-by-array (limited to '_includes/group-by-array') diff --git a/_includes/group-by-array b/_includes/group-by-array new file mode 100644 index 0000000..708de41 --- /dev/null +++ b/_includes/group-by-array @@ -0,0 +1,47 @@ + + + +{% assign __empty_array = '' | split: ',' %} +{% assign group_names = __empty_array %} +{% assign group_items = __empty_array %} + + +{% assign __names = include.collection | map: include.field %} + + +{% assign __names = __names | join: ',' | join: ',' | split: ',' %} + + +{% assign __names = __names | sort %} +{% for name in __names %} + + +{% unless name == previous %} + + +{% assign group_names = group_names | push: name %} +{% endunless %} + +{% assign previous = name %} +{% endfor %} + + + +{% for name in group_names %} + + +{% assign __item = __empty_array %} +{% for __element in include.collection %} +{% if __element[include.field] contains name %} +{% assign __item = __item | push: __element %} +{% endif %} +{% endfor %} + + +{% assign group_items = group_items | push: __item %} +{% endfor %} \ No newline at end of file -- cgit v1.2.3