Sha256: 371a616bdce1dc765760dcdde8b9e65480927cc140fc311bb84beddb951be67b

Contents?: true

Size: 898 Bytes

Versions: 10

Compression:

Stored size: 898 Bytes

Contents

require 'action_view'

module Blocks
  module ViewExtensions
    def blocks
      @blocks ||= Blocks.builder_class.new(self)
    end

    def render_with_overrides(*args, &block)
      options = args.extract_options!.with_indifferent_access
      partial = options.delete(:partial) || options.delete(:template) || args.first
      if builder = options.delete(:builder)
        builder.view = self
        # builder = builder.clone
        # TODO: figure out what to do here
      else
        # TODO: options shouldn't have to be passed both here and to the render_with_overrides call below - need it to be just one place
        builder = Blocks.builder_class.new(self, options)
      end
      builder.render_with_overrides(options.merge(partial: partial), &block)
    end
    alias_method :with_template, :render_with_overrides

  end
end

ActionView::Base.send :include, Blocks::ViewExtensions

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
blocks-3.0.4 lib/blocks/action_view_extensions/view_extensions.rb
blocks-3.0.3 lib/blocks/action_view_extensions/view_extensions.rb
blocks-3.0.2 lib/blocks/action_view_extensions/view_extensions.rb
blocks-3.0.1 lib/blocks/action_view_extensions/view_extensions.rb
blocks-3.0.0 lib/blocks/action_view_extensions/view_extensions.rb
blocks-3.0.0.rc9 lib/blocks/action_view_extensions/view_extensions.rb
blocks-3.0.0.rc8 lib/blocks/action_view_extensions/view_extensions.rb
blocks-3.0.0.rc7 lib/blocks/action_view_extensions/view_extensions.rb
blocks-3.0.0.rc6 lib/blocks/action_view_extensions/view_extensions.rb
blocks-3.0.0.rc5 lib/blocks/action_view_extensions/view_extensions.rb