Last active
June 28, 2019 12:15
-
-
Save pepelsbey/9334494 to your computer and use it in GitHub Desktop.
Removing duplicates from Liquid array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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: ', ' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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