Class: Grapple::Components::Actions

Inherits:
HtmlComponent show all
Defined in:
lib/grapple/components/actions.rb

Instance Attribute Summary

Attributes inherited from BaseComponent

#builder, #columns, #params, #records, #template

Instance Method Summary collapse

Methods inherited from BaseComponent

#initialize, setting

Constructor Details

This class inherits a constructor from Grapple::Components::BaseComponent

Instance Method Details

#render(actions = [], &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/grapple/components/actions.rb', line 7

def render(actions = [], &block)
	html = capture_block(&block)
	actions.each do |action|
		if action.kind_of?(String)
			html << action
		else
			label = t(action[:label])
			url = action[:url]
			html_attr = action.dup
			html_attr.delete(:label)
			html_attr.delete(:url)
			html << template.send(link_to_helper, label, url, html_attr)
		end
	end			
	(:div, html.html_safe, class: 'actions')
end