Sha256: 3d4c6e9165a1e79ca915f8b67660dde6434f821d3ae27366c99caf3d95214a1e

Contents?: true

Size: 880 Bytes

Versions: 196

Compression:

Stored size: 880 Bytes

Contents

module Jets::RenderingHelper
  # ensure that we always add the controller view name. So when rendering
  # a partial:
  #   <%= render "mypartial" %>
  # gets turned into:
  #   <%= render "articles/mypartial" %>
  def render(options = {}, locals = {}, &block)
    if options.is_a?(String) && !options.include?('/')
      folder = _get_containing_folder(caller[0])
      partial_name = options # happens to be the partial name
      partial_name = "#{folder}/#{partial_name}"
      options = partial_name
    end

    super(options, locals, &block)
  end

  # Ugly, going back up the caller stack to find out what view path
  # we are in
  def _get_containing_folder(caller_line)
    text = caller_line.split(':').first
    # .../fixtures/apps/demo/app/views/posts/index.html.erb
    text.split('/')[-2] # posts
  end
end
ActionView::Helpers.send(:include, Jets::RenderingHelper)

Version data entries

196 entries across 196 versions & 3 rubygems

Version Path
jets-1.9.21 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.20 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.19 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.18 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.17 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.16 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.15 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.14 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.13 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.12 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.11 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.10 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.9 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.8 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.7 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.6 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.5 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.4 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.3 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.2 lib/jets/overrides/rails/rendering_helper.rb