Sha256: 9dce4153c5cd88d0a873daa43b5efdc91c6eb0acd599758fa921ee0eb2e75806

Contents?: true

Size: 1.22 KB

Versions: 10

Compression:

Stored size: 1.22 KB

Contents

require 'ecm/cms/database_resolver'

module Ecm
  module Cms
    class PageResolver < ::ActionView::Resolver
      require 'singleton'
      include Singleton

      # add shared behaviour for database backed templates
      include Ecm::Cms::DatabaseResolver

      def build_source(record)
        output = ''
        record.ecm_cms_page_content_blocks.each do |content_block|
          # rendered_body = RedCloth.new(begin;content_block.body;end).to_html.html_safe
          rendered_body = RedCloth.new(content_block.body).to_html
          output << "<% content_for :#{content_block.content_box_name} do %>#{rendered_body}<% end %>"
        end

        content_for_title = "<% content_for :title do %>#{record.title}<% end %>"
        content_for_meta_description = "<% content_for :meta_description do %>#{record.meta_description}<% end %>"
        output << content_for_title << content_for_meta_description
        
        unless record.body.nil?
          output << record.body
        end

        return output
      end

      def normalize_basename(basename)
        basename
      end

      def resolve(partial_flag)
        !partial_flag
      end

      def template_class
        'Ecm::Cms::Page'
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
ecm_cms2-1.1.1 lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
ecm_cms2-1.1.0 lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
ecm_cms2-1.0.1 lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
ecm_cms-1.0.5.pre lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
ecm_cms2-1.0.0 lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
ecm_cms-1.0.4.pre lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
ecm_cms-1.0.3.pre lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
ecm_cms-1.0.2.pre lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
ecm_cms-1.0.1.pre lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
ecm_cms-1.0.0.pre lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb