Sha256: 639489bdddc24602ab8b8bfaefd1427f02437ca60854158b131bfe641718539a

Contents?: true

Size: 764 Bytes

Versions: 4

Compression:

Stored size: 764 Bytes

Contents

require "rails/application_controller"

module Lookbook
  class PageController < Rails::ApplicationController
    helper UiElementsHelper
    helper PageHelper

    Lookbook.config.page_paths.each do |path|
      prepend_view_path Rails.root.join(path)
    end

    def render_page(page, locals = {})
      @page = page
      @pages = Engine.pages
      @next_page = @pages.next(@page)
      @previous_page = @pages.previous(@page)

      content = ActionViewConfigHandler.call do
        render_to_string inline: @page.content, locals: {
          page: @page,
          next_page: @next_page,
          previous_page: @previous_page,
          pages: @pages
        }
      end

      @page.markdown? ? MarkdownRenderer.call(content) : content
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lookbook-2.3.4 app/controllers/lookbook/page_controller.rb
lookbook-2.3.3 app/controllers/lookbook/page_controller.rb
lookbook-2.3.2 app/controllers/lookbook/page_controller.rb
lookbook-2.3.0 app/controllers/lookbook/page_controller.rb