diff options
Diffstat (limited to 'juick-www/src/main/java/com/mitchellbosecke/pebble')
-rw-r--r-- | juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java | 2 | ||||
-rw-r--r-- | juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/TagsListFilter.java | 23 |
2 files changed, 25 insertions, 0 deletions
diff --git a/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java b/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java index 220e0460..198e9668 100644 --- a/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java +++ b/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/FormatterExtension.java @@ -2,6 +2,7 @@ package com.mitchellbosecke.pebble.extension; import com.mitchellbosecke.pebble.extension.filters.FormatMessageFilter; import com.mitchellbosecke.pebble.extension.filters.PrettyTimeFilter; +import com.mitchellbosecke.pebble.extension.filters.TagsListFilter; import java.util.HashMap; import java.util.Map; @@ -15,6 +16,7 @@ public class FormatterExtension extends AbstractExtension { Map<String, Filter> filters = new HashMap<>(); filters.put("formatMessage", new FormatMessageFilter()); filters.put("prettyTime", new PrettyTimeFilter()); + filters.put("tagsList", new TagsListFilter()); return filters; } } diff --git a/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/TagsListFilter.java b/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/TagsListFilter.java new file mode 100644 index 00000000..55c98307 --- /dev/null +++ b/juick-www/src/main/java/com/mitchellbosecke/pebble/extension/filters/TagsListFilter.java @@ -0,0 +1,23 @@ +package com.mitchellbosecke.pebble.extension.filters; + +import com.juick.Tag; +import com.mitchellbosecke.pebble.extension.Filter; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * Created by vitalyster on 23.05.2017. + */ +public class TagsListFilter implements Filter { + @Override + public Object apply(Object input, Map<String, Object> args) { + return ((List<Tag>) input).stream().map(Tag::getName).collect(Collectors.toList()); + } + + @Override + public List<String> getArgumentNames() { + return null; + } +} |