Sha256: 193d4e0f1e131adce99680dfa95dd933f6b85d2265913adb5804cec240a9a7a9

Contents?: true

Size: 586 Bytes

Versions: 1

Compression:

Stored size: 586 Bytes

Contents

require "erb"

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

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

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

  private
    def indent(string, amount)
      lines = string.lines.to_a
      result = lines.shift
      lines.each do |line|
        result << line.gsub(/^(?!$)/, " " * amount)
      end
      result
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sprockets-export-0.9.1 lib/sprockets/export/template.rb