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.



64
65
66
67
68
# File 'lib/i18n-js/export_files_plugin.rb', line 64

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

Instance Attribute Details

#fileObject

Returns the value of attribute file.



62
63
64
# File 'lib/i18n-js/export_files_plugin.rb', line 62

def file
  @file
end

#templateObject

Returns the value of attribute template.



62
63
64
# File 'lib/i18n-js/export_files_plugin.rb', line 62

def template
  @template
end

#translationsObject

Returns the value of attribute translations.



62
63
64
# File 'lib/i18n-js/export_files_plugin.rb', line 62

def translations
  @translations
end

Instance Method Details



70
71
72
73
74
75
# File 'lib/i18n-js/export_files_plugin.rb', line 70

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

#renderObject



77
78
79
# File 'lib/i18n-js/export_files_plugin.rb', line 77

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