Module: EaselHelpersLite::Helpers

Defined in:
lib/easel_helpers_lite/helpers.rb

Instance Method Summary collapse

Instance Method Details

#body(*args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/easel_helpers_lite/helpers.rb', line 3

def body(*args)
  @_classes ||= []
  @_classes += args.select(&:present?).map do |arg|
    arg.to_s.strip
  end.uniq

  if block_given?
    attributes = {}
    attributes[:class] = @_classes.join(" ") if @_classes.length > 0
    (:body, capture {yield}, attributes)
  else
    nil
  end
end


18
19
20
21
22
23
# File 'lib/easel_helpers_lite/helpers.rb', line 18

def link_button(*args, &block)
  doc = Nokogiri(link_to(*args, &block))
  doc.at("a").inner_html = "<span>#{doc.at("a").inner_html}</span>"
  (doc/:a).add_class("btn")
  raw(doc.to_html)
end

#submit_button(*args, &block) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/easel_helpers_lite/helpers.rb', line 25

def submit_button(*args, &block)
  button_text = args.first
  options = args.extract_options!
  klass = options[:class] || "btn"

  ("button", :type => "submit", :class => klass) do
    if block_given?
      yield
    else
      ("span", button_text)
    end
  end
end