From eda46a3bad28b9a7c809afdc8fc92a5bf0b03e34 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 28 May 2016 21:21:17 +0100 Subject: [PATCH] Add filter for getting category from all --- pelicanconf.py | 3 ++- plugins/filters.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pelicanconf.py b/pelicanconf.py index 0f6f8d3..d8b36dc 100644 --- a/pelicanconf.py +++ b/pelicanconf.py @@ -82,6 +82,7 @@ SITEMAP = { import filters JINJA_FILTERS = { "datetime": filters.format_datetime, - "raw": filters.html_to_raw + "raw": filters.html_to_raw, + "category_find": filters.category_find } # Extra context diff --git a/plugins/filters.py b/plugins/filters.py index 4789504..90fe26e 100644 --- a/plugins/filters.py +++ b/plugins/filters.py @@ -11,3 +11,10 @@ def html_to_raw(html): for script in soup(["script", "style"]): # Remove script / style tags script.extract() return soup.get_text() + + +def category_find(categories, name): + for category_name, articles in categories: + if category_name == name: + return articles + return []