Module: ApplicationHelper

Defined in:
app/helpers/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#widget(name, options = {}, &block) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/helpers/application_helper.rb', line 2

def widget(name, options={}, &block)
  id = Guid.new.to_s
  partial = File.join 'widgets', name.to_s
  attributes = {:id => id, :'data-widget' => name, :style => options.delete(:style), :class => options.delete(:effects)}
  options[:widget_id] = id unless options.include? :widget_id

  contents = if block_given?
               render :layout => partial, :inline => capture(&block), :locals => options, :formats => [:html]
             else
               render :template => partial, :locals => options
             end

   :div, contents, attributes
end