diff --git a/lib/locomotive/liquid/filters/base.rb b/lib/locomotive/liquid/filters/base.rb new file mode 100644 index 00000000..638b09ed --- /dev/null +++ b/lib/locomotive/liquid/filters/base.rb @@ -0,0 +1,47 @@ +module Locomotive + module Liquid + module Filters + module Base + + protected + + # Convert an array of properties ('key:value') into a hash + # Ex: ['width:50', 'height:100'] => { :width => '50', :height => '100' } + def args_to_options(*args) + options = {} + args.flatten.each do |a| + if (a =~ /^(.*):(.*)$/) + options[$1.to_sym] = $2 + end + end + options + end + + # Write options (Hash) into a string according to the following pattern: + # ="", ="