class I18n::JS::SprocketsExtension

@api private The class cannot be private

@api private

Public Class Methods

call(input) click to toggle source
# File lib/i18n/js/engine.rb, line 77
def self.call(input)
  filename = input[:filename]
  source   = input[:data]
  context  = input[:environment].context_class.new(input)

  result = run(filename, source, context)
  context.metadata.merge(data: result)
end
new(filename, &block) click to toggle source
# File lib/i18n/js/engine.rb, line 51
def initialize(filename, &block)
  @filename = filename
  @source   = block.call
end
run(filename, source, context) click to toggle source
# File lib/i18n/js/engine.rb, line 60
def self.run(filename, source, context)
  if context.logical_path == "i18n/filtered"
    ::I18n.load_path.each { |path| context.depend_on(File.expand_path(path)) }

    # Absolute path is required or
    # Sprockets assumes it's a logical path
    #
    # Calling `depend on` with an absent file
    # will invoke `resolve` and will throw an error in the end
    if I18n::JS.config_file_exists?
      context.depend_on(File.expand_path(I18n::JS.config_file_path))
    end
  end

  source
end

Public Instance Methods

render(context, empty_hash_wtf) click to toggle source
# File lib/i18n/js/engine.rb, line 56
def render(context, empty_hash_wtf)
  self.class.run(@filename, @source, context)
end