Module: LucyCms::ViewMethods

Defined in:
lib/LucyCMS/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/LucyCMS/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 => LucyCms::FormBuilder)), &proc)
end

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

Injects some content somewhere inside cms admin area



24
25
26
# File 'lib/LucyCMS/view_methods.rb', line 24

def cms_hook(name, options = {})
  LucyCms::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


39
40
41
42
43
# File 'lib/LucyCMS/view_methods.rb', line 39

def cms_page_content(block_label, page = nil)
  return '' unless page ||= @cms_page
  return '' unless block = page.cms_blocks.find_by_label(block_label)
  block.content.to_s.html_safe
end

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



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

def cms_site_form_for(record_or_name_or_array, *args, &proc)
  options = args.extract_options!
  form_for(record_or_name_or_array, *(args << options.merge(:builder => LucyCms::SiteFormBuilder)), &proc)
end

#cms_snippet_content(snippet_slug) ⇒ Object

Content of a snippet. Example:

cms_snippet_content(:my_snippet)


30
31
32
33
# File 'lib/LucyCMS/view_methods.rb', line 30

def cms_snippet_content(snippet_slug)
  return '' unless snippet = CmsSnippet.find_by_slug(snippet_slug)
  snippet.content.to_s.html_safe
end

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

Rails 3.0 doesn’t have this helper defined



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

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>



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

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