mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Add default filter to standard filters
This commit is contained in:
@@ -245,6 +245,11 @@ module Liquid
|
||||
apply_operation(input, operand, :%)
|
||||
end
|
||||
|
||||
def default(input, default_value = "")
|
||||
is_blank = input.respond_to?(:empty?) ? input.empty? : !input
|
||||
is_blank ? default_value : input
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def flatten_if_necessary(input)
|
||||
|
||||
Reference in New Issue
Block a user