Module: ComfortableMexicanSofa::ViewMethods

Defined in:
lib/comfortable_mexican_sofa/view_methods.rb

Instance Method Summary collapse

Instance Method Details

#cms_form_for(record_or_name_or_array, *args, &proc) ⇒ Object

Wrapper around CmsFormBuilder



3
4
5
6
# File 'lib/comfortable_mexican_sofa/view_methods.rb', line 3

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

#cms_hook(name, options = {}) ⇒ Object

Injects some content somewhere inside cms admin area



19
20
21
# File 'lib/comfortable_mexican_sofa/view_methods.rb', line 19

def cms_hook(name, options = {})
  ComfortableMexicanSofa::ViewHooks.render(name, self, options)
end

#cms_page_content(block_label, page = nil) ⇒ Object

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


35
36
37
38
39
# File 'lib/comfortable_mexican_sofa/view_methods.rb', line 35

def cms_page_content(block_label, page = nil)
  return '' unless page ||= @cms_page
  return '' unless block = page.blocks.find_by_label(block_label)
  render :inline => ComfortableMexicanSofa::Tag.process_content(page, block.content)
end

#cms_snippet_content(snippet_slug, cms_site = nil) ⇒ Object

Content of a snippet. Example:

cms_snippet_content(:my_snippet)


25
26
27
28
29
# File 'lib/comfortable_mexican_sofa/view_methods.rb', line 25

def cms_snippet_content(snippet_slug, cms_site = nil)
  return '' unless cms_site ||= (@cms_site || Cms::Site.find_by_hostname(request.host.downcase))
  return '' unless snippet = cms_site.snippets.find_by_slug(snippet_slug)
  render :inline => ComfortableMexicanSofa::Tag.process_content(Cms::Page.new, snippet.content)
end

#datetime_field_tag(name, value = nil, options = {}) ⇒ Object

Rails 3.0 doesn’t have this helper defined



14
15
16
# File 'lib/comfortable_mexican_sofa/view_methods.rb', line 14

def datetime_field_tag(name, value = nil, options = {})
  text_field_tag(name, value, options.stringify_keys.update('type' => 'datetime'))
end

#span_tag(*args) ⇒ Object

Wrapper for <span>



9
10
11
# File 'lib/comfortable_mexican_sofa/view_methods.rb', line 9

def span_tag(*args)
  (:span, *args)
end