class Object

Public Instance Methods

nice_partials_locale_prefix_from_view_context_and_block(context, block) click to toggle source

TODO Is there somewhere better we can put this?

# File lib/nice_partials.rb, line 11
def nice_partials_locale_prefix_from_view_context_and_block(context, block)
  root_paths = context.view_renderer.lookup_context.view_paths.map(&:path)
  partial_location = block.source_location.first.dup
  root_paths.each { |path| partial_location.gsub!(/^#{path}\//, '') }
  partial_location.split('.').first.gsub('/_', '/').gsub('/', '.')
end