mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 15:30:39 -07:00
Added filters for basic arithmetic
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user