module RulesEngineView module FormStyles def re_build_form_field(value, options = {}) result = '' result << "
" result end def re_build_form_label value, options = {} result = " " result end def re_build_form_data value, options = {} result = " " result end def re_options_exclude(options) options.except(:error, :hint, :label, :text, :required, :span) end def re_label_span(options) span = options[:span] if span =~ %r{^\d+x\d+$} return span.split("x")[0].to_i elsif span =~ %r{^\d+$} return span.to_i end return 4 end def re_data_span(options) span = options[:span] if span =~ %r{^\d+x\d+$} return span.split("x")[1].to_i elsif span =~ %r{^\d+$} if span.to_i < 8 return 8 - span.to_i elsif span.to_i < 16 return 16 - span.to_i else return 24 - span.to_i end end return 8 end def re_field_span(options) re_label_span(options) + re_data_span(options) end end end ActionView::Base.class_eval do include RulesEngineView::FormStyles end