Add filter for getting category from all
This commit is contained in:
parent
8ad6364690
commit
eda46a3bad
2 changed files with 9 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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 []
|
||||
|
|
Reference in a new issue