Class: Rake::Pipeline::I18n::Filters::EmberStringsFilter

Inherits:
Filter
  • Object
show all
Includes:
FilterWithDependencies
Defined in:
lib/rake-pipeline-i18n-filters/ember_strings_filter.rb

Overview

A filter that compiles locale yml files into javascript appropriate for use by Ember#String#loc

Examples:

Rake::Pipeline.build do
  input "config/locales", "**/*.yml"
  output "public"

  # Compile each .yml file under the config/locales
  # directory.
  filter Rake::Pipeline::Web::Filters::EmberI18nFilter
end

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ EmberStringsFilter

Note:

If you are using Ember.String.loc be sure to set Ember.STRINGS = EmberI18n;

where ‘locale’ is the locale you have parsed and want to render.

Parameters:

  • options (Hash)

    A hash of options for this filter

  • block (Proc)

    a block to use as the Filter’s #output_name_generator.

  • [String] (Hash)

    a customizable set of options

See Also:



35
36
37
38
# File 'lib/rake-pipeline-i18n-filters/ember_strings_filter.rb', line 35

def initialize(&block)
  block ||= proc { |input| input.sub(/\.(yml)$/, '.js') }
  super(&block)
end

Instance Method Details

#generate_output(inputs, output) ⇒ Object

Implement the #generate_output method required by the Filter API. Generates javascript from i18n yaml files appropriate for Ember#String#loc or i18n-js

Parameters:

  • inputs (Array<FileWrapper>)

    an Array of FileWrapper objects representing the inputs to this filter.

  • output (FileWrapper)

    a single FileWrapper object representing the output.



48
49
50
# File 'lib/rake-pipeline-i18n-filters/ember_strings_filter.rb', line 48

def generate_output(inputs, output)
    output.write ember_i18n_output(inputs)
end