Sha256: c4ae860612616e2783502365931f12d17338e23229ebea343c719c7670fb1b8a

Contents?: true

Size: 988 Bytes

Versions: 27

Compression:

Stored size: 988 Bytes

Contents

module Pageflow
  # Helper class to be used as `editor_fragment_renderer` of
  # {EntryType} objects to render fragments from partials.
  #
  # @since 15.1
  class PartialEditorFragmentRenderer
    # Create object that implements methods required by
    # `editor_fragment_renderer` of {EntryType}.
    #
    # @param controller [ActionController::Base] Renders partials in
    #   the context of this controller. The controller determines
    #   which helpers are available in the template
    def initialize(controller)
      @renderer = controller.renderer
    end

    def head_fragment(entry)
      render('head', entry)
    end

    def body_fragment(entry)
      render('body', entry)
    end

    def seed_fragment(entry)
      render('seed', entry, format: :json)
    end

    private

    def render(partial, entry, format: :html)
      @renderer.render(partial: partial,
                       formats: format,
                       locals: {entry: entry})
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
pageflow-17.0.4 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-17.0.3 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-17.0.2 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-17.0.1 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-17.0.0 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-16.2.0 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-16.1.0 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-16.0.0 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-15.8.0 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-15.7.1 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-15.7.0 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-15.6.1 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-15.6.0 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-15.5.0 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-15.4.0 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-15.3.0 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-15.2.2 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-15.2.1 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-15.2.0 lib/pageflow/partial_editor_fragment_renderer.rb
pageflow-15.1.2 lib/pageflow/partial_editor_fragment_renderer.rb