Sha256: 86ca4488e92145aeec625e963bcdadd1355fc828eb1f475ee944536a0d10b6c2

Contents?: true

Size: 915 Bytes

Versions: 2

Compression:

Stored size: 915 Bytes

Contents

class String
  # Converts string to something suitable to be used as an element id
  def idify
    self.strip.gsub(/\W/, '_').gsub(/\s|^_*|_*$/, '').squeeze('_')
  end
  
  # Capitalize all words in the string
  def capitalize_all(delimiter = ' ')
    self.split(delimiter).collect{|w| w.capitalize }.join(' ')
  end
end

module CmsViewHelpers
  
  # Wrapper around CmsFormBuilder
  def cms_form_for(record_or_name_or_array, *args, &proc)
    options = args.extract_options!
    form_for(record_or_name_or_array, *(args << options.merge(:builder => CmsFormBuilder)), &proc)
  end
  
  # Wrapper for <span>
  def span_tag(*args)
    content_tag(:span, *args)
  end
  
  # Rails 3.0 doesn't have this helper defined
  def datetime_field_tag(name, value = nil, options = {})
    text_field_tag(name, value, options.stringify_keys.update('type' => 'datetime'))
  end
end

ActionView::Base.send :include, CmsViewHelpers 

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.0.1 lib/comfortable_mexican_sofa/cms_rails_extensions.rb
comfortable_mexican_sofa-1.0.0 lib/comfortable_mexican_sofa/cms_rails_extensions.rb