Module: NicePartials::RenderingWithLocalePrefix

Defined in:
lib/nice_partials/monkey_patch.rb

Overview

Monkey patch required to make ‘t` work as expected. Is this evil? TODO Do we need to monkey patch other types of renderers as well?

Instance Method Summary collapse

Instance Method Details

#capture(&block) ⇒ Object



6
7
8
# File 'lib/nice_partials/monkey_patch.rb', line 6

def capture(*, &block)
  with_nice_partials_t_prefix(lookup_context, block) { super }
end

#t(key, options = {}) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/nice_partials/monkey_patch.rb', line 10

def t(key, options = {})
  if (prefix = @_nice_partials_t_prefix) && key.first == '.'
    key = "#{prefix}#{key}"
  end

  super(key, **options)
end