Sha256: 7d4f784317d8e531a895b76fe131bd0797695c8441c75906ee8b088d810466f2

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 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

        output << record.body unless record.body.nil?

        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

8 entries across 8 versions & 1 rubygems

Version Path
ecm_cms2-3.0.0 lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
ecm_cms2-2.1.3 lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
ecm_cms2-2.1.2 lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
ecm_cms2-2.1.1 lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
ecm_cms2-2.1.0 lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
ecm_cms2-2.0.4 lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
ecm_cms2-2.0.3 lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb
ecm_cms2-2.0.2 lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb