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-2.3.7 lib/jets/overrides/rails/rendering_helper.rb
jets-2.3.6 lib/jets/overrides/rails/rendering_helper.rb
jets-2.3.5 lib/jets/overrides/rails/rendering_helper.rb
jets-2.3.4 lib/jets/overrides/rails/rendering_helper.rb
jets-2.3.3 lib/jets/overrides/rails/rendering_helper.rb
jets-2.3.2 lib/jets/overrides/rails/rendering_helper.rb
jets-2.3.1 lib/jets/overrides/rails/rendering_helper.rb
jets-2.3.0 lib/jets/overrides/rails/rendering_helper.rb
jets-2.2.5 lib/jets/overrides/rails/rendering_helper.rb
jets-2.2.4 lib/jets/overrides/rails/rendering_helper.rb
jets-2.2.3 lib/jets/overrides/rails/rendering_helper.rb
jets-2.2.2 lib/jets/overrides/rails/rendering_helper.rb
jets-2.2.1 lib/jets/overrides/rails/rendering_helper.rb
jets-2.2.0 lib/jets/overrides/rails/rendering_helper.rb
jets-2.1.7 lib/jets/overrides/rails/rendering_helper.rb
jets-2.1.6 lib/jets/overrides/rails/rendering_helper.rb
jets-2.1.5 lib/jets/overrides/rails/rendering_helper.rb
jets-2.1.4 lib/jets/overrides/rails/rendering_helper.rb
jets-2.1.3 lib/jets/overrides/rails/rendering_helper.rb
jets-2.1.2 lib/jets/overrides/rails/rendering_helper.rb