Class: I18nJS::ExportFilesPlugin::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n-js/export_files_plugin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ Template

Returns a new instance of Template.



83
84
85
86
87
# File 'lib/i18n-js/export_files_plugin.rb', line 83

def initialize(**kwargs)
  kwargs.each do |key, value|
    public_send("#{key}=", value)
  end
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



81
82
83
# File 'lib/i18n-js/export_files_plugin.rb', line 81

def file
  @file
end

#templateObject

Returns the value of attribute template.



81
82
83
# File 'lib/i18n-js/export_files_plugin.rb', line 81

def template
  @template
end

#translationsObject

Returns the value of attribute translations.



81
82
83
# File 'lib/i18n-js/export_files_plugin.rb', line 81

def translations
  @translations
end

Instance Method Details



89
90
91
92
93
94
# File 'lib/i18n-js/export_files_plugin.rb', line 89

def banner(comment: "// ", include_time: true)
  [
    "#{comment}File generated by i18n-js",
    include_time ? " on #{Time.now}" : nil
  ].compact.join
end

#renderObject



96
97
98
# File 'lib/i18n-js/export_files_plugin.rb', line 96

def render
  ERB.new(File.read(template)).result(binding)
end