Module: Trestle::ToolbarsHelper

Defined in:
app/helpers/trestle/toolbars_helper.rb

Instance Method Summary collapse

Instance Method Details

#deprecated_toolbar(name) ⇒ Object



28
29
30
31
32
33
# File 'app/helpers/trestle/toolbars_helper.rb', line 28

def deprecated_toolbar(name)
  if content_for?(:"#{name}_toolbar")
    ActiveSupport::Deprecation.warn("Using content_for(:#{name}_toolbar) is deprecated. Please use toolbar(:#{name}) instead.")
    content_for(:"#{name}_toolbar")
  end
end

#render_toolbar(toolbar, *args) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/trestle/toolbars_helper.rb', line 14

def render_toolbar(toolbar, *args)
  result = toolbar.groups(self, *args).map do |items|
    if items.many?
      (:div, class: "btn-group", role: "group") do
        safe_join(items, "\n")
      end
    else
      items.first
    end
  end

  safe_join(result, "\n")
end

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



3
4
5
6
7
8
# File 'app/helpers/trestle/toolbars_helper.rb', line 3

def toolbar(name, options={}, &block)
  toolbar = (toolbars[name.to_s] ||= Toolbar.new)
  toolbar.clear! if options[:clear]
  toolbar.prepend(&block) if block_given?
  toolbar
end

#toolbarsObject



10
11
12
# File 'app/helpers/trestle/toolbars_helper.rb', line 10

def toolbars
  @_toolbars ||= {}
end