Sha256: 51b44fa51c959d89e83498f1b1585320dfc70a600a1dddae2801f9135410c1a8

Contents?: true

Size: 567 Bytes

Versions: 5

Compression:

Stored size: 567 Bytes

Contents

module ApplicationHelper
  # Applies an html class attribute where the controller name contains the 'tab_name'.
  def tab_on(tab_name, html_class="current_page_item")
    controller_name.match(Regexp.new("#{tab_name}")) ? " class=\"#{html_class}\"" : ''
  end

  # Produces a string id using the type and id of obj plus any field suffix supplied useful when
  # assigning html ids on index pages.
  # e.g. element_id(user, 'name') => 'User_23_name'
  def element_id(obj, field="")
    obj.class.to_s + '_' + obj.id.to_s + (field.blank? ? '' : '_' + field)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
branston-0.4.3 lib/branston/app/helpers/application_helper.rb
branston-0.4.2 lib/branston/app/helpers/application_helper.rb
branston-0.4.1 lib/branston/app/helpers/application_helper.rb
branston-0.4.0 lib/branston/app/helpers/application_helper.rb
branston-0.3.6 lib/branston/app/helpers/application_helper.rb