Module: LRD::ViewHelper

Defined in:
lib/app/helpers/lrd_view_helper.rb

Instance Method Summary collapse

Instance Method Details

#block_to_partial(partial_name, options = {}, &block) ⇒ Object

Passes the supplied block to the named partial



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/app/helpers/lrd_view_helper.rb', line 17

def block_to_partial(partial_name, options = {}, &block)
  # replace :id with :cssid and :class with :cssclass
  if options[:id]
    options[:cssid] = options.delete(:id)
  else
    options[:cssid] = "" if options[:cssid].nil?
  end
  if options[:class]
    options[:cssclass] = options.delete(:class)
  else
    options[:cssclass] = "" if options[:cssclass].nil?
  end

  options.merge!(:body => capture(&block))
  render(:partial => partial_name, :locals => options)
end

#bool_checked(field) ⇒ Object

displays a checkmark if the field is set true



10
11
12
13
# File 'lib/app/helpers/lrd_view_helper.rb', line 10

def bool_checked(field)
  filename = field ? "check.png" : "blank.gif"
  image_tag(filename, :alt => "yes", :size => "16x16")
end

#page_block(title = nil, options = {}, &block) ⇒ Object

a standardized view helper that renders a box with an optional title. The standard partial for it is in views/shared/_page_block.html.haml



36
37
38
# File 'lib/app/helpers/lrd_view_helper.rb', line 36

def page_block(title = nil, options = {}, &block)
  block_to_partial('shared/block', options.merge(:title => title), &block).html_safe
end

#set_headline(headline) ⇒ Object

Stores a headline for later rendering by the layout



5
6
7
# File 'lib/app/helpers/lrd_view_helper.rb', line 5

def set_headline(headline)
  content_for(:headline, headline)
end