Module: ComfortableMexicanSofa::ViewMethods
- Defined in:
- lib/comfortable_mexican_sofa/view_methods.rb
Instance Method Summary collapse
-
#cms_hook(name, options = {}) ⇒ Object
Injects some content somewhere inside cms admin area.
-
#cms_page_content(identifier, page = nil) ⇒ Object
Content of a page block.
-
#cms_snippet_content(identifier, cms_site = nil) ⇒ Object
Content of a snippet.
-
#comfy_form_for(record_or_name_or_array, *args, &proc) ⇒ Object
Wrapper around CmsFormBuilder.
-
#span_tag(*args) ⇒ Object
Wrapper for <span>.
Instance Method Details
#cms_hook(name, options = {}) ⇒ Object
Injects some content somewhere inside cms admin area
14 15 16 |
# File 'lib/comfortable_mexican_sofa/view_methods.rb', line 14 def cms_hook(name, = {}) ComfortableMexicanSofa::ViewHooks.render(name, self, ) end |
#cms_page_content(identifier, 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(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 |
#cms_snippet_content(identifier, cms_site = nil) ⇒ Object
Content of a snippet. Example:
cms_snippet_content(:my_snippet)
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/comfortable_mexican_sofa/view_methods.rb', line 20 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 |
#comfy_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 comfy_form_for(record_or_name_or_array, *args, &proc) = args. form_for(record_or_name_or_array, *(args << .merge(:builder => ComfortableMexicanSofa::FormBuilder)), &proc) 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) content_tag(:span, *args) end |