Added filters for basic arithmetic

This commit is contained in:
James MacAulay
2008-10-15 11:02:25 -04:00
parent 3bfde37a53
commit 69bc84b777
2 changed files with 36 additions and 0 deletions
+20
View File
@@ -155,6 +155,26 @@ module Liquid
array.last if array.respond_to?(:last)
end
# addition
def plus(input, operand)
input + operand if input.respond_to?('+')
end
# subtraction
def minus(input, operand)
input - operand if input.respond_to?('-')
end
# multiplication
def times(input, operand)
input * operand if input.respond_to?('*')
end
# division
def divided_by(input, operand)
input / operand if input.respond_to?('/')
end
end
Template.register_filter(StandardFilters)