Sha256: f4bcf5bf0736a60516b4d44a77326d0db4025aade185480639438e1b59f563ce
Contents?: true
Size: 944 Bytes
Versions: 59
Compression:
Stored size: 944 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) 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_lines) caller_line = caller_lines.find { |l| !l.include?('/gems/') } 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
59 entries across 59 versions & 2 rubygems