Added more filters for Liquid to work with bad lists

This commit is contained in:
frikky
2023-03-28 19:28:44 +02:00
parent 2ce53cf10d
commit 8203f4b648
+24
View File
@@ -154,6 +154,30 @@ def flatten(a):
flat_list = [a for xs in a for a in xs]
return flat_list
@shuffle_filters.register
def last(a):
try:
a = json.loads(a)
except:
pass
if len(a) == 0:
return ""
return a[-1]
@shuffle_filters.register
def first(a):
try:
a = json.loads(a)
except:
pass
if len(a) == 0:
return ""
return a[0]
@shuffle_filters.register
def csv_parse(a):