Sha256: b5fccc2c56ed33126e7ff1396ee09e59d84af2ea3bf276ce04506906c4106a29

Contents?: true

Size: 1.56 KB

Versions: 12

Compression:

Stored size: 1.56 KB

Contents

module ComfortableMexicanSofa::ViewMethods
  # 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 => ComfortableMexicanSofa::FormBuilder)), &proc)
  end
  
  # Wrapper for <span>
  def span_tag(*args)
    content_tag(:span, *args)
  end
  
  # Injects some content somewhere inside cms admin area
  def cms_hook(name, options = {})
    ComfortableMexicanSofa::ViewHooks.render(name, self, options)
  end
  
  # Content of a snippet. Example:
  #   cms_snippet_content(:my_snippet)
  def cms_snippet_content(identifier, cms_site = nil)
    return '' unless cms_site ||= (@cms_site || Cms::Site.find_site(request.host.downcase, request.fullpath))
    case identifier
    when Cms::Snippet
      snippet = identifier
    else
      return '' unless snippet = cms_site.snippets.find_by_identifier(identifier)
    end
    render :inline => ComfortableMexicanSofa::Tag.process_content(cms_site.pages.build, snippet.content)
  end
  
  # Content of a page block. This is how you get content from page:field
  # Example:
  #   cms_page_content(:left_column, CmsPage.first)
  #   cms_page_content(:left_column) # if @cms_page is present
  def cms_page_content(identifier, page = nil)
    return '' unless page ||= @cms_page
    return '' unless block = page.blocks.find_by_identifier(identifier)
    render :inline => ComfortableMexicanSofa::Tag.process_content(page, block.content)
  end
end

ActionView::Base.send :include, ComfortableMexicanSofa::ViewMethods

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.6.11 lib/comfortable_mexican_sofa/view_methods.rb
comfortable_mexican_sofa-1.6.10 lib/comfortable_mexican_sofa/view_methods.rb
comfortable_mexican_sofa-1.6.9 lib/comfortable_mexican_sofa/view_methods.rb
comfortable_mexican_sofa-1.6.8 lib/comfortable_mexican_sofa/view_methods.rb
comfortable_mexican_sofa-1.6.7 lib/comfortable_mexican_sofa/view_methods.rb
comfortable_mexican_sofa-1.6.6 lib/comfortable_mexican_sofa/view_methods.rb
comfortable_mexican_sofa-1.6.5 lib/comfortable_mexican_sofa/view_methods.rb
comfortable_mexican_sofa-1.6.4 lib/comfortable_mexican_sofa/view_methods.rb
comfortable_mexican_sofa-1.6.3 lib/comfortable_mexican_sofa/view_methods.rb
comfortable_mexican_sofa-1.6.2 lib/comfortable_mexican_sofa/view_methods.rb
comfortable_mexican_sofa-1.6.1 lib/comfortable_mexican_sofa/view_methods.rb
comfortable_mexican_sofa-1.6.0 lib/comfortable_mexican_sofa/view_methods.rb