Module: Jets::RenderingHelper
- Defined in:
- lib/jets/rails_overrides/rendering_helper.rb
Instance Method Summary collapse
-
#_get_containing_folder(caller_line) ⇒ Object
Ugly, going back up the caller stack to find out what view path we are in.
-
#render(options = {}, locals = {}, &block) ⇒ Object
ensure that we always add the controller view name.
Instance Method Details
#_get_containing_folder(caller_line) ⇒ Object
Ugly, going back up the caller stack to find out what view path we are in
20 21 22 23 24 |
# File 'lib/jets/rails_overrides/rendering_helper.rb', line 20 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 |
#render(options = {}, locals = {}, &block) ⇒ Object
ensure that we always add the controller view name. So when rendering a partial:
<%= render "mypartial" %>
gets turned into:
<%= render "articles/mypartial" %>
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/jets/rails_overrides/rendering_helper.rb', line 7 def render( = {}, locals = {}, &block) if .is_a?(String) && !.include?('/') folder = _get_containing_folder(caller[0]) partial_name = # happens to be the partial name partial_name = "#{folder}/#{partial_name}" = partial_name end super(, locals, &block) end |