Add logic to exclude some pages based on some tags

This commit is contained in:
Clément Fournier
2018-05-21 09:41:41 +02:00
parent bb51792ba7
commit 918a812d92
3 changed files with 27 additions and 20 deletions

View File

@ -1,27 +1,24 @@
module CustomFilters
def contains_all(input, test)
if !test
!input
elsif !input
false
def intersect(xs, ys)
if !xs || !ys
[]
else
test.split(",").all? {|val| input.include?(val)}
Array(xs) & Array(ys)
end
end
def intersect(xs, ys)
xs & ys
def equals(xs, ys)
a = Array(xs)
b = Array(ys)
((a | b) - (a & b)).empty?
end
def union(xs, ys)
xs | ys
def empty(xs)
Array(xs).empty?
end
def diff(xs, ys)
xs - ys
end
end
Liquid::Template.register_filter(CustomFilters)

View File

@ -1,6 +1,5 @@
# This tag takes a variable name as an input, and evaluates its value twice
# (follows one indirection)
# This tag takes a variable name as an input, and evaluates its value twice (dereferences it once)
# E.g. if the symbol table is E = {"foo" => "bar", "bar" => "baz"},
# then {% eval foo %} ~> E[E["foo"]] ~> E["bar"] ~> "baz"