Sha256: 6e30878fcdf617d034958d2c643a62102b06202f5f4613fd271ab477ca6f1951

Contents?: true

Size: 460 Bytes

Versions: 1

Compression:

Stored size: 460 Bytes

Contents

require 'render_with_view/version'
require 'render_with_view/half_open_struct'

module RenderWithView
  class View < HalfOpenStruct
  end

  def render_with_view *args
    if !args.first.is_a?(Hash)
      tmpl = args.shift
    else
      tmpl = action_name
    end
    locals = args.shift
    opts = args.shift || {}

    # save to ivar for testing purposes
    @__view__ = View.new(locals)

    render tmpl, opts.merge(locals: { view: @__view__ })
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
render_with_view-0.1.3 lib/render_with_view.rb