Sha256: b89402a92580337ae0be947855234776538c270cf01b3a9afbaf9352e2c449c8

Contents?: true

Size: 963 Bytes

Versions: 10

Compression:

Stored size: 963 Bytes

Contents

require 'sinatra/base'
require 'sprockets/helpers'

module Sinatra
  module Sprockets
    module Helpers
      def self.registered(app)
        app.helpers ::Sprockets::Helpers
        app.configure_sprockets_helpers
      end

      def configure_sprockets_helpers(&block)
        ::Sprockets::Helpers.configure do |helpers|
          with_setting(:sprockets) { |value| helpers.environment = value }
          with_setting(:public_folder) { |value| helpers.public_path = value }
          with_setting(:digest_assets) { |value| helpers.digest = value }
          with_setting(:assets_prefix) { |value| helpers.prefix = value }
        end
        ::Sprockets::Helpers.configure(&block) if block_given?
      end

      private

        def with_setting(name, &block)
          return unless settings.respond_to?(name)

          value = settings.__send__(name)
          yield value unless value.nil?
        end
    end
  end

  register Sprockets::Helpers
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
sprockets-helpers-1.4.0 lib/sinatra/sprockets/helpers.rb
sprockets-helpers-1.3.0 lib/sinatra/sprockets/helpers.rb
sprockets-helpers-1.2.3 lib/sinatra/sprockets/helpers.rb
sprockets-helpers-1.2.2 lib/sinatra/sprockets/helpers.rb
arcabouco-0.2.13 vendor/bundle/gems/sprockets-helpers-1.2.1/lib/sinatra/sprockets/helpers.rb
sprockets-helpers-1.2.1 lib/sinatra/sprockets/helpers.rb
sprockets-helpers-1.2.0 lib/sinatra/sprockets/helpers.rb
sprockets-helpers-1.1.0 lib/sinatra/sprockets/helpers.rb
sprockets-helpers-1.0.1 lib/sinatra/sprockets/helpers.rb
sprockets-helpers-1.0.0 lib/sinatra/sprockets/helpers.rb