Class: Sprockets::Export::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/sprockets/export/template.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Template

Returns a new instance of Template.



8
9
10
11
12
# File 'lib/sprockets/export/template.rb', line 8

def initialize(data = {})
  data.each do |key, value|
    instance_variable_set("@#{key}".to_sym, value)
  end
end

Class Method Details

.contentObject



4
5
6
# File 'lib/sprockets/export/template.rb', line 4

def self.content
  @content ||= Sprockets::Export.lib_path.join("sprockets/export/template.js.erb").read
end

Instance Method Details

#renderObject



14
15
16
# File 'lib/sprockets/export/template.rb', line 14

def render
  ERB.new(self.class.content, nil, "-").result(binding).strip + "\n"
end