Sha256: f48e3549327103c898e27d7bd68e66619d59e46ef27a1e9247daf8abe6a1b92b

Contents?: true

Size: 881 Bytes

Versions: 6

Compression:

Stored size: 881 Bytes

Contents

require 'sinatra/base'
require 'coffee-script'
require 'uglifier'
require 'sass'
require 'sprockets'

module AssetHelpers
  def asset_path(name)
    settings.sprockets.path(name, true, "assets")
  end
end

class App < Sinatra::Base
  set :root, File.expand_path('../', __FILE__)
  set :sprockets, Sprockets::Environment.new(root)
  set :precompile, [ /\w+\.(?!js|css).+/, /application.(css|js)$/ ]
  set :assets_prefix, 'assets'
  set :assets_path, File.join(root, 'public', assets_prefix)
  
  configure do
    sprockets.append_path(File.join(root, 'assets', 'stylesheets'))
    sprockets.append_path(File.join(root, 'assets', 'javascripts'))
    sprockets.append_path(File.join(root, 'assets', 'images'))

    sprockets.context_class.instance_eval do
      include AssetHelpers
    end
  end
  
  helpers do
    include AssetHelpers
  end
  
  get "/" do
    erb :index
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
guard-sprockets2-0.0.6 examples/sinatra_app/app.rb
guard-sprockets2-0.0.5 examples/sinatra_app/app.rb
guard-sprockets2-0.0.4 examples/sinatra_app/app.rb
guard-sprockets2-0.0.3 examples/sinatra_app/app.rb
guard-sprockets2-0.0.2 examples/sinatra_app/app.rb
guard-sprockets2-0.0.1 examples/sinatra_app/app.rb