Sha256: 4863ebc42707ec98414c0f37dc2cf0d0f8af3354886a7d9982e5e78e2b217f4e
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
module ComfortableMexicanSofa::ViewMethods # Wrapper around ComfortableMexicanSofa::FormBuilder def comfy_form_for(record, options = {}, &proc) options[:builder] = ComfortableMexicanSofa::FormBuilder options[:type] ||= :horizontal formatted_form_for(record, options, &proc) 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) # If block is a page_file(s) we will return objects instead of attempting # to render them out case block.tag when ComfortableMexicanSofa::Tag::PageFile block.files.first when ComfortableMexicanSofa::Tag::PageFiles block.files else render :inline => ComfortableMexicanSofa::Tag.process_content(page, block.content) end end end ActionView::Base.send :include, ComfortableMexicanSofa::ViewMethods
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
comfortable_mexican_sofa-1.7.1 | lib/comfortable_mexican_sofa/view_methods.rb |
comfortable_mexican_sofa-1.7.0 | lib/comfortable_mexican_sofa/view_methods.rb |