Class: Toolsmith::Views::PageHeader

Inherits:
Base
  • Object
show all
Defined in:
lib/toolsmith/views/page_header.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#context

Instance Method Summary collapse

Methods inherited from Base

#content_tag

Constructor Details

#initialize(context, title, *args) ⇒ PageHeader

Returns a new instance of PageHeader.



6
7
8
9
10
11
12
# File 'lib/toolsmith/views/page_header.rb', line 6

def initialize(context, title, *args)
  super(context)

  @options = args.extract_options!
  @title = title
  @subtitle = args.first
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/toolsmith/views/page_header.rb', line 4

def options
  @options
end

#subtitleObject

Returns the value of attribute subtitle.



4
5
6
# File 'lib/toolsmith/views/page_header.rb', line 4

def subtitle
  @subtitle
end

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/toolsmith/views/page_header.rb', line 4

def title
  @title
end

Instance Method Details

#button(*args) ⇒ Object



14
15
16
17
18
19
# File 'lib/toolsmith/views/page_header.rb', line 14

def button(*args)
  button_options = args.size >= 3 ? button_options(*args) : args.shift
  buttons << button_options

  button_options
end

#button_markup(options) ⇒ Object



21
22
23
24
25
26
# File 'lib/toolsmith/views/page_header.rb', line 21

def button_markup(options)
  anchor_options = options.fetch(:anchor, {})
  context.link_to options[:path], anchor_options.merge(class: "btn", title: options[:title]) do
     :i, "", class: "icon-#{options[:icon]}"
  end
end

#buttonsObject



28
29
30
# File 'lib/toolsmith/views/page_header.rb', line 28

def buttons
  @buttons ||= []
end

#full_titleObject



32
33
34
# File 'lib/toolsmith/views/page_header.rb', line 32

def full_title
  subtitle ? "#{ERB::Util.h(title)} #{(:small, self.subtitle)}".html_safe : ERB::Util.h(title)
end

#to_sObject



36
37
38
# File 'lib/toolsmith/views/page_header.rb', line 36

def to_s
   :div, h1_tag, class: "page-header"
end