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_bb_fork-0.0.4 lib/jets/overrides/rails/rendering_helper.rb
jets-2.1.1 lib/jets/overrides/rails/rendering_helper.rb
jets-2.1.0 lib/jets/overrides/rails/rendering_helper.rb
jets-2.0.6 lib/jets/overrides/rails/rendering_helper.rb
jets-2.0.5 lib/jets/overrides/rails/rendering_helper.rb
jets-2.0.4 lib/jets/overrides/rails/rendering_helper.rb
jets-2.0.3 lib/jets/overrides/rails/rendering_helper.rb
jets-2.0.1 lib/jets/overrides/rails/rendering_helper.rb
jets-2.0.0 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.32 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.31 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.30 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.29 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.28 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.27 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.26 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.25 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.24 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.23 lib/jets/overrides/rails/rendering_helper.rb
jets-1.9.22 lib/jets/overrides/rails/rendering_helper.rb