Module: Trestle::ToolbarsHelper
- Defined in:
- app/helpers/trestle/toolbars_helper.rb
Instance Method Summary collapse
- #deprecated_toolbar(name) ⇒ Object
- #render_toolbar(toolbar, *args) ⇒ Object
- #toolbar(name, options = {}, &block) ⇒ Object
- #toolbars ⇒ Object
Instance Method Details
#deprecated_toolbar(name) ⇒ Object
28 29 30 31 32 33 |
# File 'app/helpers/trestle/toolbars_helper.rb', line 28 def (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 (, *args) result = .groups(self, *args).map do |items| if items.many? content_tag(: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 (name, ={}, &block) = ([name.to_s] ||= Toolbar.new) .clear! if [:clear] .prepend(&block) if block_given? end |
#toolbars ⇒ Object
10 11 12 |
# File 'app/helpers/trestle/toolbars_helper.rb', line 10 def @_toolbars ||= {} end |