Class: Aureus::Components::Box
Instance Method Summary
collapse
Methods inherited from Renderable
#compact, #compact_render, #content_tag, #init
Constructor Details
#initialize(title, options, &block) ⇒ Box
Returns a new instance of Box.
7
8
9
10
11
12
13
|
# File 'lib/aureus/components/box.rb', line 7
def initialize title, options, &block
init options, for: :text, centered: false
init_haml_helpers
@title = title
@buttons = Array.new
@content = capture_haml self, &block
end
|
Instance Method Details
23
24
25
|
# File 'lib/aureus/components/box.rb', line 23
def button content
@buttons << BoxButton.new(content)
end
|
#content(&block) ⇒ Object
15
16
17
|
# File 'lib/aureus/components/box.rb', line 15
def content &block
@new_content = capture_haml &block
end
|
19
20
21
|
# File 'lib/aureus/components/box.rb', line 19
def &block
@foot = capture_haml &block
end
|
#render ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/aureus/components/box.rb', line 27
def render
title = content_tag('h3',compact(content_tag('span', @title),compact_render(*@buttons)))
classes = ['box']
classes << 'centered' if @options[:centered]
@content = @new_content if !@new_content.nil?
content_tag 'div', class: classes.join(' ') do
case @options[:for]
when :form
@content = content_tag('ul', @content, class: 'content')
end
= @foot.nil? ? '' : content_tag('div', @foot, class: 'foot')
compact title, content_tag('div', @content),
end
end
|