Sha256: a08c5ad6d4b54a2a9cb08626ff81314257034b96de713a1f1598a411ececf9fe

Contents?: true

Size: 1.02 KB

Versions: 15

Compression:

Stored size: 1.02 KB

Contents

module Simplec
  module PageActionHelpers

    # @private
    module ClassMethods; end

    module InstanceMethods

      private

      # Render the template and layout for a path.
      #
      # @param path [String] a path without a leading /
      # @param options [Hash] passed through to underlying `render`
      #
      # @!visibility public
      def render_path(path, options={})
        @page = page(path)
        render options.merge(
          template: 'simplec/pages/show',
          layout: layout(@page)
        )
      end

      # Determine the layout for a page.
      #
      # @param page [Simplec::Page]
      #
      # @return [String] layout name
      # @!visibility public
      def layout(page)
        # TODO allow config for public
        [page.layout, page.subdomain.default_layout, 'public'].
          reject(&:blank?).first
      end

    end

    # @!visibility private
    def self.included(receiver)
      receiver.extend         ClassMethods
      receiver.send :include, InstanceMethods
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
simplec-0.10.1 lib/simplec/page_action_helpers.rb
simplec-0.10.0 lib/simplec/page_action_helpers.rb
simplec-0.9.2 lib/simplec/page_action_helpers.rb
simplec-0.9.1 lib/simplec/page_action_helpers.rb
simplec-0.9.0 lib/simplec/page_action_helpers.rb
simplec-0.8.1 lib/simplec/page_action_helpers.rb
simplec-0.8.0 lib/simplec/page_action_helpers.rb
simplec-0.7.1 lib/simplec/page_action_helpers.rb
simplec-0.7.0 lib/simplec/page_action_helpers.rb
simplec-0.6.0 lib/simplec/page_action_helpers.rb
simplec-0.5.0 lib/simplec/page_action_helpers.rb
simplec-0.4.4 lib/simplec/page_action_helpers.rb
simplec-0.4.3 lib/simplec/page_action_helpers.rb
simplec-0.4.2 lib/simplec/page_action_helpers.rb
simplec-0.4.1 lib/simplec/page_action_helpers.rb