module Gumdrop::Support::Sprockets

Public Instance Methods

sprockets(source_file, opts={}) click to toggle source
# File lib/gumdrop/support/sprockets.rb, line 6
def sprockets(source_file, opts={})
  require 'sprockets'
  source_path = source_file || opt[:main] || opt[:from]
  env = ::Sprockets::Environment.new site.root
  env.append_path File.expand_path(File.join site.source_path, File.dirname(source_path))
  env.append_path site.source_path
  # env.append_path File.dirname(source_path)
  [opts[:paths]].flatten.each do |path|
    env.append_path(path) unless path.nil?
  end
  content= env[ source_path ].to_s
rescue LoadError
  raise StandardError, "Sprockets can't be loaded. Please add it to your Gemfile."
end