1
而不是幾乎有兩個類似的自定義包裝定義,是否可以將它們烘乾?對於e.g:幹掉simple_form中的自定義包裝
config.wrappers :inline_checkbox, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
b.use :html5
b.wrapper :tag => 'div', :class => 'controls' do |ba|
ba.use :label_input, :wrap_with => { :class => 'checkbox inline' }
ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
end
end
和
config.wrappers :inline_checkbox_two, :tag => 'div', :class => 'control-group', :error_class => 'error' do |b|
b.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
# everything else should use the same definition as the above
end
此使用比特解構和紅寶石2.0關鍵字參數。你可以在這裏閱讀更多關於它的信息:http://tony.pitluga.com/2011/08/08/destructuring-with-ruby.html和這裏:https://robots.thoughtbot.com/ruby-2-keyword-參數 – max