Sha256: 2cbd1de1c09a5cf876efe8eccc4cf56332a7ec2821e6adc6c5fc4b6d1b15106d

Contents?: true

Size: 912 Bytes

Versions: 1

Compression:

Stored size: 912 Bytes

Contents

module Blocks
  class PartialRenderer < AbstractRenderer
    def render(partial, options={}, &block)
      if !options.is_a?(Blocks::RuntimeContext)
        options = RuntimeContext.new(builder, options).to_hash.with_indifferent_access.deep_dup
      end
      overrides_and_provided_content = capture(builder, options, &block) if block_given?
      locals = options.merge(
        (options[:builder_variable] || :builder) => builder,
      )
      locals = if locals.respond_to?(:deep_symbolize_keys)
        locals.deep_symbolize_keys
      else
        locals.symbolize_keys
      end
      locals[:options] = options
      view.render(layout: partial, locals: locals) do |*args|
        if overrides_and_provided_content
          overrides_and_provided_content.to_str.gsub(/PLACEHOLDER_FOR_([\w]+)/) do |s|
            builder.render $1, *args
          end.html_safe
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blocks-3.0.0.rc7 lib/blocks/renderers/partial_renderer.rb