Sha256: c1a80bc4d9294fc1560801f1f70d81edbf965395ff0e682d916c28b7368169ec

Contents?: true

Size: 505 Bytes

Versions: 1

Compression:

Stored size: 505 Bytes

Contents

require "erb"

class Sprockets::Export::Template
  CONTENT = Pathname.new(__dir__).join("template.js.erb").read

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

  def render
    ERB.new(CONTENT).result(binding)
  end

  private
    def indent(string, amount)
      lines = string.lines
      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.0 lib/sprockets/export/template.rb