Sha256: 189a8dc9a81bc77d38ade1ab55807a9f1ce4ffa2e209f81154e754ae108b6846
Contents?: true
Size: 1.83 KB
Versions: 1
Compression:
Stored size: 1.83 KB
Contents
module GenericFormFor module Actions module Base include I18n def wrap_in(*args, &block) wrap_options = args.last.is_a?(Hash) ? args.pop : {} wrap_options[:class] = [*"#{options[:as]}-action", *wrap_options[:class], *(options[:wrapper_html]||{})[:class]].join(' ').strip wrap_options.merge!((options[:wrapper_html] || {}).except(:class)) template.concat( template.content_tag(wrap_options.delete(:tag) || :div, wrap_options) do template.capture(&block) if block_given? end.html_safe) end attr_accessor :builder, :template, :object, :object_name, :method, :options def initialize(builder, template, object, object_name, method, options) @output_buffer = "" @builder = builder @template = template @object = object @object_name = object_name @method = method @options = options.dup end def to_html instance_exec &builder.action_wrapper_proc "" end def merge_action_html_options(runtime_options,config_options) runtime_options[:class] = [*runtime_options[:class], *config_options[:class]].compact.join(' ').strip config_options.merge(runtime_options) end def action_html_options default_action_options.merge(options[:html] || {}).merge(action_options) end def default_action_options {:name => method, :type => method } end def action_options options.except(*form_builder_options) end def form_builder_options [:as, :url, :icon, :icon_html] end def button_text translate_action(options[:label] || method) end extend ActiveSupport::Autoload # autoload :Icon end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
generic_form_for-0.0.1 | lib/generic_form_for/actions/base.rb |