Removing duplicates from Liquid array
{% assign array = 'c|c|b|b|a|a' | split: '|' %} | |
{% assign tags = array[1] %} | |
{% for item in array %} | |
{% unless tags contains item %} | |
{% capture tags %}{{ tags }}|{{ item }}{% endcapture %} | |
{% endunless %} | |
{% endfor %} | |
{{ tags | split: '|' | sort | join: ', ' }} |
module Jekyll | |
module KeepUnique | |
def keep_unique(input) | |
input.to_s.split('|').uniq | |
end | |
end | |
end | |
Liquid::Template.register_filter(Jekyll::KeepUnique) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment